in reply to Re^3: How to do encryption in perl with aes-128-cbc
in thread How to do encryption in perl with aes-128-cbc

Actually i usd perl package management and in that there are no direct packages and wondering for the exact pkg.

found it and installed it and now i'm able to run it in cmd but while executing it in 'padre' it still showing the same error.

but in the code i've used 32 bit key and 32 bit iv values. now it is asking for the 16 bit iv values.

C:\Windows\system32>ppm install CryptX Downloading CryptX-0.013...done Unpacking CryptX-0.013...done Generating HTML for CryptX-0.013...done Updating files in site area...done 137 files installed this is the error message : Initialization vector must be exactly 16 bytes long when using the Cipher::AES cipher at cipher2.pl line 6
use Crypt::CBC; use Crypt::OpenSSL::AES; my $key = '2bbacc08ace4f431eafc8dca13908007'; my $iv = '5345435245545f4b45595f3132333435'; my $cbc = Crypt::CBC->new( -cipher=>'Cipher::AES', -key=>$key, -iv=>$i +v ); my $ciphertext = $cbc->encrypt("secret data"); print $ciphertext;

help me with this. is there any way that i can specify the length of key and iv values.??

Replies are listed 'Best First'.
Re^5: How to do encryption in perl with aes-128-cbc
by Corion (Patriarch) on Aug 30, 2013 at 10:56 UTC

    I don't know anything about CryptX, and you seem to be using Crypt::CBC, which has no relation to CryptX. I note that your $iv and $key variables seem to contain hexadecimal digits. The Crypt::CBC documentation indicates that you should use the string without any encoding. If you unpack your hex string into the real bytes, maybe that helps.

    I don't know if there is a way to specify initialization vectors of other lengths, but maybe if you read the documentation, you find more information.

      Thanks for the quick replay. let me check the details and let me see what i can understand and what i can do.

        Thanks for the information.

        I tried tried converting hext o 16 bit string and then used in the code.

        Finally it worked.

        once again thanks for the information.

        you made my day, waiting for this since last 2 days