in reply to Length of Crypt::CBC result

You need to read up on pack and unpack The * is a useful widget and using it fixes your problem.

use Crypt::CBC; my $What = "Some text to be encrypted."; # my $Length = length ( $What ) * 2; my $Cipher = Crypt::CBC->new ( [ key => $DBITT::CryptString ] ); my $CipherText = $Cipher->encrypt ( $What ); my $ASCII = unpack ( "H*", $CipherText ); print "Encrypted result of $What is $ASCII.\n"; print " That was " . length ( $ASCII ) . " bytes long.\n"; my $PlainText = $Cipher->decrypt ( $CipherText ); print "And back into the real world we have '$PlainText'.\n"; $PlainText = $Cipher->decrypt ( pack ( "H*", $ASCII ) ); print "Try via ASCII string it's '$PlainText'.\n"; __DATA__ Encrypted result of Some text to be encrypted. is 52616e646f6d49569aee +93f3d204172c101f93dcae2a2a94dd1142acf98a0067bdf2f0edfcb06b3543f3cf8d0 +5decc33. That was 96 bytes long. And back into the real world we have 'Some text to be encrypted.'. Try via ASCII string it's 'Some text to be encrypted.'.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Replies are listed 'Best First'.
Re: Re: Length of Crypt::CBC result
by talexb (Chancellor) on Apr 04, 2002 at 03:06 UTC
    I swear that I tried out "H*" and it failed with flying colours. And now I try it again and I can see plainly that it works. Oy.

    Murphy lives. Thanks.

    --t. alex

    "Here's the chocolates, and here's the flowers. Now how 'bout it, widder hen, will ya marry me?" --Foghorn Leghorn