narse has asked for the wisdom of the Perl Monks concerning the following question:
Here is the code I have written attempting to follow the specification: (@lock_arr is the string to change, each character is at its own index)the key is quite easily :) computed from the lock key[x]= ns(lock[x]^lock[x-1]) ns is a nibble swap (switch the upper 4 bits with the lower 4 bits) exception: ey[0] is a bit different let's name A and B the 2 last bytes of the lock key[0]= ns(lock[0]^A^B^0x05) ; 0x05 is a kind of magic nibble
As far as I know, I have two problems here.$key_arr[0] = pack 'h2', unpack 'H2', ( $lock_arr[0] ^ $lock_arr[@lock_arr - 1] ^ $lock_arr[@lock_arr - 2] ); for (my $i=1; $i<@lock_arr; $i++) { $key_arr[$i] = pack 'h2', unpack 'H2', ($lock_arr[$i] ^ $lock_arr[$i-1]); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Low level operations
by Zaxo (Archbishop) on Oct 08, 2002 at 23:48 UTC | |
by narse (Pilgrim) on Oct 09, 2002 at 16:33 UTC | |
|
Re: Low level operations
by thor (Priest) on Oct 09, 2002 at 04:14 UTC | |
by Anonymous Monk on Oct 09, 2002 at 10:44 UTC | |
by Anonymous Monk on Oct 09, 2002 at 10:51 UTC | |
by Anonymous Monk on Oct 09, 2002 at 11:30 UTC | |
by sch (Pilgrim) on Oct 09, 2002 at 10:54 UTC | |
by thor (Priest) on Oct 09, 2002 at 12:58 UTC | |
by narse (Pilgrim) on Oct 09, 2002 at 16:01 UTC |