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]); }
In reply to Low level operations by narse
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |