in reply to perl encryptions keys vs. c

There's something wrong with:
@k = unpack( 'C*', pack( 'H*', shift ) );
I tried with key "ciao" and @k ends up with only two elements instead of 4 as in the C version, which operates on all 4 characters. I really don't know anything about pack/unpack, so I cannot solve the problem without studying it, and it's friday afternoon :)

Update: sorry, fried in friday, I completely missed the pre-calculations over the input key, ikegami answer forced me to take a deeper look. I swear I'll re-read it, in the meantime "--" me!

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

Replies are listed 'Best First'.
Re^2: perl encryptions keys vs. c
by ikegami (Patriarch) on Apr 22, 2005 at 19:03 UTC
    The Perl version is expecting the key to be represented as hex digits. Try '6369616F' instead of 'ciao' for the Perl version (making @k = ('c', 'i', 'a', 'o')). I'm too lazy to figure out whatI don't know what the C version expects.