Important alert: (current site time 7/15/2013 8:46:13 PM EDT)
 

VB icon

Encryption in Blowfish

Email
Submitted on: 4/18/2003 4:10:43 PM
By: Damian myerscough  
Level: Intermediate
User Rating: By 2 Users
Compatibility: 5.0 (all versions), Active Perl specific, 4.0 (all versions), 3.0 (all versions), Pre 3.0
Views: 10620
 
     Encrypt Private Data
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
=**************************************
= Name: Encryption in Blowfish
= Description:Encrypt Private Data
= By: Damian myerscough
=
= Returns:Encrypted Data
=
= Side Effects:If you lose the key which is needed your data will be lost
=
=This code is copyrighted and has= limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=449&lngWId=6=for details.=**************************************

#!/usr/bin/perl -w
#
# Blowfish Encryption By; Damian Myerscough
#
use Crypt::CBC;
use Crypt::Blowfish;
# The Cipher Settings
$cipher = Crypt::CBC->new({'key'=> '007xDamox700',
'cipher' => 'Blowfish',
'iv' => '![$`2}%q',
'regenerate_key' => 0,
'padding'=> 'space',
'prepend_iv' => 0
 });
$ciphertext = $cipher->encrypt("I program in perl");
print"Encrypted Data: $ciphertext \n";
$text = $cipher->decrypt($ciphertext);
print"Decrypted Data: $text \n";


Other 35 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/18/2003 4:26:25 PMAaron L. Anderson

What I don't get about encryption like this is, how is it secure? Blowfish is probably a pretty big perl encryption module most programmers/hackers know of. If they can break into your server and access your logs, what's to stop them from testing out random modules until they find a way to read the data?

My impression is, you can use a premade module but you need to roll-your-own in the end. Encrypt it once with Blowfish then once more with your encryption, then to decrypt it you'd need two programs (one which the hacker cannot have)..
(If this comment was disrespectful, please report it.)

 
4/19/2003 2:18:58 AMBenjamin Tilley

Reverse engineering the algorithm in Blowfish has yet to be done (to my knowledge) so I'd hardly worry about that. As for homemade encryption, unless you are very familar with the algorithms and advanced mathematics I'd not reccomend doing something like that. It is far more likely that someone will guess your key than break the modules.

That being said, this code isn't well documented so I'm unsure of certain parts. Decent "hello world" using the blowfish module though.
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.