473,396 Members | 1,864 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,396 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 6841
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.