in reply to Hex String XOR
You need to pack the hex representation into a binary string, so if you have '112233' you need to create the bytes "\x11\x22\x33". Then you can use the bitwise operators on these byte strings to do what you want.
Here's a nice way to do the conversions:
use strict; use warnings; use 5.010; # just needed for say() sub unascii { pack 'h*', $_[0]; } sub ascii { unpack 'h*', $_[0]; } say ascii unascii('aabbcc') ^ unascii('112233'); # output: bb99ff
See pack, unpack and perlpacktut for more details.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Hex String XOR
by ikegami (Patriarch) on Mar 12, 2012 at 18:45 UTC |