|
-
June 23rd, 2003, 02:15 AM
#7
slarty -- I recently had a need for the same thing, only in Perl. I used blowfish for that along with a simple algorithm that took 16 characters from the string to encrypt at a time, unpacked it into hex, and fed it through the blowfish module. If you know anything about Perl, this should make it a bit clearer:
my $i=0;
my $Blowfish_Key = $in{'key'};
my $Blowfish_Cipher = new Crypt::Blowfish $Blowfish_Key;
my $Password = $in{'password'}
my $Encrypted = "";
my $Decrypted = "";
for($i=0;$i!=-1;$i+=8){
my $linechunk = substr($Password, $i, 8);
$Encrypted .= unpack("H16",$Blowfish_Cipher->encrypt(pack("A8",$linechunk)));
if(length($linechunk)<7){ last; }
}
I'm afraid I don't know much about a C translation, though. When decrypting, I just did the reverse:
my $Retrieved = $in{'cyphered'};
for($i=0;$i!=-1;$i+=16){
my $linechunk = substr($Retrieved, $i, 16);
if(length($linechunk)<1){ last; }
$Decrypted .= $Blowfish_Cipher->decrypt(pack("H16", $linechunk));
if(length($linechunk)<15){ last; }
}
/* You are not expected to understand this. */
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|