Hi
Heres the code:
use Blowfish;
$blowfishkey=pack("H*",'5b3b272e5d39342d33313d3d2d252640215e2b5d00');
$packet = pack("H*",'071bdba4419a1e4e');
$cipher = new Crypt::Blowfish $blowfishkey;
print "Key: $blowfishkey\n";
print "Crypted packet: $packet\n";
$packet = $cipher->decrypt($packet);
print "Decrypted packet: $packet\n";
$packet = "\x00WildMaN";
print "Initial known packet: $packet\n";
$packet = $cipher->encrypt($packet);
print "Should be encrypted as: $packet\n";
I know the blowfish key. I know the string that was encrypted. I know the final encrypted packet. But if i decrypt it with perl Blowfish, or encrypt initial packet - it does not work, result is trash.
I've tried it on Java - works fine. I've tried it on C# - perfect. But on Perl it outputs trash. The only thing i can suggest is some internal troubles with string encodings, or maybe a bug within Crypt::Blowfish (my initial packet starts with zero character)... I have no ideas left, it works perfect on Java and C#.
Instead of "\x00WildMaN" (0057696c644d614e) i get this trash as decryption: 090216d5bf90386d.
20040915 Edit by castaway: Changed title from 'Problem with Blowfish'
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.