I am trying to develop a CGI sendable encryption scheme using blowfish to let CGI's talk to each other on different servers. Here is the question:
I use Crypt:Blowfish and a for loop to chop the string up into 8 byte pieces and feed them through the module.
This works fine save for the fact that get out many many "funky characters" such as :my @textCharacters = split( // , $plainText ); for( $j = 0 ; $j <= ( length( $plainText )/8 )-1 ; $j++ ) { $z = ""; for( $k = 0 ; $k <= 7; $k++ ) { $i = $j*8 + $k; $z .= $textCharacters[$i]; } print "STRING"; print "Z = X $z X \n"; my $cipher = new Crypt::Blowfish $key; $cryptText .= $cipher->encrypt( $z ); }
These are making my telnet connection act odd as well as preventing the next step of the project which is remapping the chracterset of the Blowfish output into a simpler ( CGI Safe string ). I have that working for the ascii characters but not for the output characters that Blowfish puts out. I designed the remapping system to take the 256 chracters of the standard ASCII set:7Æ Mb¢[ñF%L;Á^ô¥ X
and that will output a string of numbers that represent 4 characters. It does more after that but this is the start. The blowfish output characters causes this to return negative values. I though mabye that it is working on 16 bit characters like unicode does and I upped the alphabet size to 2^16 but I still get negative values.my @glyphs; my $plainText = $_[0]; # Pad string to divisible by glyph choice my $padLength; if( length( $plainText ) % 3 ne "0" ) { $padLength = 3 - ( length( $plainText ) % 3 ); } $plainText .= " "x$padLength; print " pad = $padLength , $plainText X\n"; # Convert text to ASCII @asciiCodes = unpack( "c*", $plainText ); for( $j = 0 ; $j <= ( length( $plainText )/3 )-1 ; $j++ ) { my $sum = 0; for( $k = 0 ; $k <= 2 ; $k++ ) { $i = ( $j*3 + $k ); $sum += @asciiCodes[$i] * ( 65536 ** ( 2-$k ) ); } push( @glyphs , $sum ); } return( @glyphs );
Any ideas?
In reply to Blowfish Cypher by Angel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |