in reply to Rewriting a C# Encryption Function
my $data= pack('cccccccc',49,0,50,0,51,0,52,0); print sha1_hex($data); print sha1_base64($data);
prints out 139f69c93c042496a8e958ec5930662c6cccafbf, which is the hex form of your result and E59pyTwEJJao6VjsWTBmLGzMr78
So your c# encryption routine converts your string rather pointlessly IMHO to unicode and then hashes it. The pack method above has obvious limits, as soon as a char isn't in the same place on page 0 of the unicode charset your hash will be different again.
Do you need the new hash conform to the old or was it just the correctness of the code that was important?
UPDATE: http://perldoc.perl.org/Encode.html might provide methods to get at the underlying bytes of the unicode
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Rewriting a C# Encryption Function
by bkiahg (Pilgrim) on Aug 22, 2008 at 21:45 UTC | |
by gone2015 (Deacon) on Aug 22, 2008 at 23:35 UTC | |
by bkiahg (Pilgrim) on Aug 25, 2008 at 14:26 UTC | |
|
Re^2: Rewriting a C# Encryption Function
by bkiahg (Pilgrim) on Aug 22, 2008 at 21:20 UTC | |
by jethro (Monsignor) on Aug 22, 2008 at 21:55 UTC | |
by graff (Chancellor) on Aug 23, 2008 at 00:14 UTC |