• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 429
  • Last Modified:

PERL and Blowfish


Recently I got a PERL program written that will encrypt file using Blowfish. I need some changes but am unable to
trace that person and I am not a PERL programmer. I am a VB.NET Programmer. I have installed PERL 5.8 from http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-
and Crypt-Blowfish_PP.

Following are my queries:

a. The file cryptdata.pl has the following line:
use Crypt::Blowfish;
But the client wants to use Crypt-Blowfish_PP and that is what I have downloaded and insgtalled. Since I am running this under windows and the source is pure text, can I change the line to use Crypt::Blowfish_PP; using NotePad? Will this impact the encryption code written by the earlier programmer?

b. Also can I change the line:
 my $proc = new Crypt::Blowfish $key_valid;
my $proc = new Crypt::BlowfishPP $key_valid;

c. The source file has:
my $key = "My key"
Now this key is in pure text format. How can I encrypt this
key itself? Otherwise programmers who will use this
source file can see the key which is not good. In other
words, I need to put the encrypted key and then decrypt
it at run-time. If this is not possible, then can I compile
this cryptdata.pl file into an executable? If yes, how? or is there any third party tool that can convert my .pl file into an exe?

d. What is difference between Blowfish and Blowfish_PP? Will the output differ if I change Blowfish to Blowfish_PP?


  • 2
1 Solution
the output should be identical if you just change Crypt::Blowfish to Crypt::Blowfish_PP
Crypt::Blowfish_PP is implemented purely in Perl so it is more portable, while Crypt::Blowfish compiled in C so it is faster.
You can get the key at run time.  
a) According to the doc available at CPAN you can simply replace the use-call by the Crypt::Blowfish_PP one :)
b) It's actually "my $blowfish=new Crypt::Blowfish_PP ($key);" ;)
c) IMO you'd need a key to decrypt your crypted in-source key (which has to be supplied somehow.. eg. Add a prompt asking for the phrase on startup).
d) PP = PurePerl.. Which means it doesn't have to be compiled using a compiler.. but is slower than the C implementation of blowfish used in Crypt::Blowfish.

On a sidenote: You might wanna get Crypt::Blowfish (without the _PP) from activeperl's own repository.. Check ppm install Crypt_Blowfish (or something along the lines).
ppm.bat is a helper tool for accessing the ActivePerl module repository from the command line.. It can be found at %ACTIVEPERLINSTALLATIONDIRECTORY%/bin/ppm.bat :)


Thanks for the points :)

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now