CGI-SecureState

 view release on metacpan or  search on metacpan

SecureState.pm  view on Meta::CPAN

515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
    $buffer = "";
} else {
    #parse metadata
    $block^=$buffer;
    $self->{'.age'} = unpack("N",substr($block,4,4));
    $length = unpack("N",substr($block,0,4));
    $extra = ($length % 8) ? (8-($length % 8)) : 0;
    $decoded=-8;
 
    #sanity check
    if ((stat(STATEFILE))[7] != ($length+$extra+8))
    { $self->errormsg('invalid state file') }
 
    #read the rest of the file
    sysseek(STATEFILE, 8, $SEEK_SET);
    unless (sysread(STATEFILE,$buffer,$length+$extra) == ($length+$extra))
    { $self->errormsg('invalid state file') }
 
    my $next_block;
    $block = $cipher->decrypt(substr($buffer,0,8));
    #decrypt it



( run in 0.269 second using v1.01-cache-2.11-cpan-0d8aa00de5b )