473,233 Members | 1,606 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,233 software developers and data experts.

Script using Crypt::CBC encryption/decryption

180 100+
Hello friends,

I am new to Perl scripts.
Please help me out....

I am using crypt::CBC to encrypt my files...

during decryption process it goes through the code as follows
Expand|Select|Wrap|Line Numbers
  1. if ($header_mode eq 'salt') {
  2.     my ($salt) = $$input_stream =~ /^Salted__(.{8})/s;
  3.     croak "Ciphertext does not begin with a valid header for 'salt' header mode" unless defined $salt;
  4.     $self->{salt} = $salt;          # new salt
  5.     substr($$input_stream,0,16) = '';
  6.     my ($key,$iv) = $self->_salted_key_and_iv($self->{passphrase},$salt);
  7.     $self->{iv} = $self->{civ}  = $iv;
  8.     $self->{key}  = $key;
  9. }
  10.  
Expand|Select|Wrap|Line Numbers
  1. my ($salt) = $$input_stream =~ /^Salted__(.{8})/s;
  2.  
Can anybody tell me what the above instruction means....

Expand|Select|Wrap|Line Numbers
  1. sub _salted_key_and_iv {
  2.     my $self = shift;
  3.     my ($pass,$salt)  = @_;
  4.  
  5.     croak "Salt must be 8 bytes long" unless length $salt == 8;
  6.  
  7.     my $key_len = $self->{keysize};
  8.     my $iv_len  = $self->{blocksize};
  9.  
  10.     my $desired_len = $key_len+$iv_len;
  11.  
  12.     my $data  = '';
  13.     my $d = '';
  14.  
  15.     while (length $data < $desired_len) {
  16.         $d = md5($d . $pass . $salt);
  17.         $data .= $d;
  18.     }
  19.     return (substr($data,0,$key_len),substr($data,$key_len,$iv_len));
  20. }
  21.  
How are they retrieve the password and the iv

Thanks,
Rajeev
Sep 3 '07 #1
3 8273
pbmods
5,821 Expert 4TB
Heya, Rajeev.

I'm going to go ahead and move this thread to the Perl forum, where our resident Experts will be better able to help you out.
Sep 3 '07 #2
miller
1,089 Expert 1GB
Expand|Select|Wrap|Line Numbers
  1. my ($salt) = $$input_stream =~ /^Salted__(.{8})/s;
  2.  
Can anybody tell me what the above instruction means....
Rajeev,

It assigns $salt to the 8 characters after Salted__ from the string $$input_stream.

I suggest that you read Crypt::CBC instead of simply using someone else's script. You'll find more clear usage description in there, and they are also 3 example scripts included in the distribution. You'll find links to them at the bottom of the cpan doc.

- Miller
Sep 3 '07 #3
numberwhun
3,509 Expert Mod 2GB
Rajeev,

It assigns $salt to the 8 characters after Salted__ from the string $$input_stream.

I suggest that you read Crypt::CBC instead of simply using someone else's script. You'll find more clear usage description in there, and they are also 3 example scripts included in the distribution. You'll find links to them at the bottom of the cpan doc.

- Miller
Welcome back miller! How was your trip?

Jeff
Sep 3 '07 #4

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

Similar topics

1
by: Jerry Maguire | last post by:
Hi, Is there any function in sql server to encrypt a column data? If not, then is it possible in ASP? Thanks jerry
2
by: Edward W. | last post by:
any good articles out there on using encryption in web.config? i'd like not to store sql server names and passwords, or conn strings for that matter in plain text. sorry - nt authentication isn't...
34
by: kpg | last post by:
Hello all, I have an asp.net web application with tons of Java script files. I would like to protect the Java Script somehow so it can't be seen by a remote user. I found several 3rd party...
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...
0
by: Sathyaish | last post by:
I am using CBC as the cipher mode to decrypt some text I'd encrypted using the same mode for 3DES algorithm. My decrypt does not return the correct result because the TransformBlock method returns...
2
by: vermarajeev | last post by:
Hi guys, I have written code to encrypt and decrypt files using perl script. Please help me to port below code to crypto++ library. //ENCRYPTION my $cipher = Crypt::CBC->new( -cipher =>...
1
by: jbot | last post by:
I have an sql server 2005 database in a shared host environment. I have an access database that links to a few of the tables over odbc. I want to set the server to require that all data be...
9
by: Alan M Dunsmuir | last post by:
In my (PHP-5) application I have to write some records to a table in my database, which I don't want even my clients using the system to be able to read. This is not a problem in National...
2
by: cmrhema | last post by:
Hi, I have to develop an application, where the user will be asked to download a file. Each user will be allocated a password. After the file downloads(preferably a notepad or a doc or a pdf) the...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.