473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to do encryption in perl with aes-128-cbc

Hi All,

once Again back with one more question.

can some one please help me how to use aes-128-cbc in perl.
I got the information like:

https://metacpan.org/module/Crypt::O...Cipher::AES128

but How can i use this in encrypting in perl.


I got some data,key and iv values and i need to encrypt it using the aes-128-cbc.


Here is some more additional information:
Expand|Select|Wrap|Line Numbers
  1. use Crypt::Mode::CBC;
  2.  
  3. my $key = '(32bit key value)'; 
  4. my $iv = '(32bit iv value)';
  5. my $cbc = Crypt::Mode::CBC->new('AES');
  6. my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
  7. print $ciphertext;
after executing the above code it is showing the error message as :

Uncaught exception from user code:

Can't locate loadable object for module CryptX in @INC (@INC contains: C
:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at
C:/Dwimperl/perl/site/lib/Crypt/Cipher.pm line 5
Compilation failed in require at C:/Dwimperl/perl/site/lib/Crypt/Cipher.pm line
5.
BEGIN failed--compilation aborted at C:/Dwimperl/perl/site/lib/Crypt/Cipher.pm l
ine 5.
Compilation failed in require at C:/Dwimperl/perl/site/lib/Crypt/Mode/CBC.pm lin
e 8.
BEGIN failed--compilation aborted at C:/Dwimperl/perl/site/lib/Crypt/Mode/CBC.pm
line 8.
Compilation failed in require at cipher1.pl line 1.
BEGIN failed--compilation aborted at cipher1.pl line 1.
at cipher1.pl line 1
Press any key to continue . . .

-----------------------------------------------------
or

Expand|Select|Wrap|Line Numbers
  1. use Crypt::CBC;
  2. use Crypt::Cipher::AES;
  3.  
  4. my $key = '(32bit key value)'; 
  5. my $iv = '(32bit iv value)';
  6. my $cbc = Crypt::CBC->new( -cipher=>'Cipher::AES', -key=>$key, -iv=>$iv );
  7. my $ciphertext = $cbc->encrypt("secret data");
  8. print $ciphertext;
after executing the above code it is showing the error message as :

Uncaught exception from user code:
Can't locate loadable object for module CryptX in @INC (@INC contains: C
:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at
C:/Dwimperl/perl/site/lib/Crypt/Cipher/AES.pm line 8
Compilation failed in require at C:/Dwimperl/perl/site/lib/Crypt/Cipher/AES.pm l
ine 8.
BEGIN failed--compilation aborted at C:/Dwimperl/perl/site/lib/Crypt/Cipher/AES.
pm line 8.
Compilation failed in require at cipher2.pl line 2.
BEGIN failed--compilation aborted at cipher2.pl line 2.
at cipher2.pl line 2
Press any key to continue . . .

-------------------------------------------------------
In this case can some one please do let me know how can i check if 'CryptX' and (related modules) are installed properly in my machine.


Thanks in adv...
Aug 29 '13 #1

✓ answered by numberwhun

It looks like module CryptX is needed by the module your using. I don't know how you are installing modules, but if your using CPAN, then you may want to turn on "follow" for how to install dependencies. That way anything needed by the module is automatically installed when you install the module you want.

Regards,

Jeff

6 6828
numberwhun
3,509 Expert Mod 2GB
It looks like module CryptX is needed by the module your using. I don't know how you are installing modules, but if your using CPAN, then you may want to turn on "follow" for how to install dependencies. That way anything needed by the module is automatically installed when you install the module you want.

Regards,

Jeff
Aug 29 '13 #2
Dear Jeff,

thanks for the replay.
just found, how to do that one and did it.

now how to install the module(cryptx) in win 32 bit machine...
Aug 30 '13 #3
Dear Jeff,

Thanks for the information. Actualy my vi key is in 32 bit and so it showed up some error askign for 16 block.

I tried tried converting hex to 16 bit string and then used in the code.
Finally it worked & all is well and all happies.

once again thanks for the information.
you made my day, waiting for this since last 2 days
Aug 30 '13 #4
So Finally revised code:

Expand|Select|Wrap|Line Numbers
  1.  
  2.  
  3.  
  4.     use Crypt::Mode::CBC;
  5.  
  6.     my $key = '(32bit key value)'; 
  7.     my $iv = '(16 bit iv plain string value)';
  8.     my $cbc = Crypt::Mode::CBC->new('AES');
  9.     my $ciphertext = $cbc->encrypt("secret data", $key, $iv);
  10.     print $ciphertext;
  11.     my $plaintext = $cbc->decrypt($ciphertext, $key, $iv);
  12.     print $plaintext;
  13.  
  14.  
  15.  
Aug 30 '13 #5
numberwhun
3,509 Expert Mod 2GB
I assume all is working ok now?
Aug 31 '13 #6
Yes it's working normal as expected.
Aug 31 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Hal Vaughan | last post by:
I have no background in encryption, so I'm working with samples I've found in various places and patching them together. I know Blowfish can use a 56 byte key. The version of this program in Perl...
4
by: Piotr Turkowski | last post by:
Hi! I've got some code in Perl and I have to have it in C, but my knowlege of Perl is < 0 :-(, so I need your help. here's the code. Thanks in advance. decrypt.pl #!/usr/local/bin/perl...
1
by: v0idnull | last post by:
Ok, so: I have a neat little freebsd server up and running with a total of 4gb of space. What I want to do is upgrade perl from 5.0003 to 5.8.6. 5.8.6 isn't in the ports tree, and when I try...
1
by: Marshall Dudley | last post by:
I have an application where I need to encrypt a bit of text, and then I need to be able to decrypt it using a customer's key. I want to make sure that the key to decrypt is NOT on the server...
3
by: DGG | last post by:
I have got a question arsing from my perl program. Basically, I want to get the machine date and time, and display it on a Tk label. I am using ActivePerl, and running on DOS/Windows. So I...
1
by: Babu | last post by:
Hi, I am a Perl newbie and have a doubt on Perl exception handling. My understanding regarding exception handling is execute a piece of code, if any exception occurs, handle the exception and...
2
by: tfoxusenet | last post by:
Hi, I need to encrypt/decrypt some data for my C# application that can also be read on a unix system, and need a quick, simple, cross-platform solution I can embed in my own code that doesn't...
1
by: josh.kuo | last post by:
First of all, I know this is a PHP news group, so my question may not be completely appropriate here since it involves some perl. I have read this post that dealt with a similar problem that I am...
4
by: Olle24 | last post by:
I've decrypted a file several times with this script: perl -ne "print map {chr ord ($_) - 54} split //, $_" example.txt They have recently changed the encryption to something else and the command...
10
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.