in reply to Crypt::OpenPGP blocksize problem

#this sub makes all data blocksize of 16 bytes. sub get16 { my $data = shift; print "data=$data\n"; return "\0" x ( 16 - length($data)%16 ) . $data; }

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re: Re: Crypt::OpenPGP blocksize problem
by frankmanowar (Initiate) on Mar 22, 2004 at 19:28 UTC
    I, Frank, made the original request for help, but for some reason i wasn't actually logged in. Anyway, um, the block above does not help this problem at all. decrypt throws an error that no data packets were found. I utilized the above function by sending my scalar of all the crypt data as the paramter to get16 ( $Data = get16($Data) ). zentara, should the abover function be used in a line by line fashion? or is there a bug in it? I don't really understand what it does. Frank
      Don't know what your problem actually is. But I remember your error was "data not in block size 16". What the sub does is pad the string with null characters, from 1 to 15 depending, so that the data string is in nice even blocks of 16 bytes. You will see that after you decrypt, the data will be a little bigger because of the padding, but it won't affect the file. If you want to strip the file after decrypting:
      #To strip any padding after decryption: my $plaintext = $cipher->decrypt($encrypted); $plaintext =~ s/^\0+//;
      Why you are not getting the results you want is not known to me. Maybe try posting again with some code?

      I'm not really a human, but I play one on earth. flash japh