I'm trying to compute an xor in bash, and the simplest way I have found so far is to use the $(( )) construct, like this:
$ printf '0x%X\n' $(( 0xA ^ 0xF ))
0x5
However, I need to xor two 128-bit numbers (32 hexadecimal characters) and it looks like the (( )) construct does not support such large numbers. Is there a way that (( )) can handle it?
$ printf '0x%X\n' $(( 0xA ^ 0xF ))
0x5
$ printf '0x%X\n' $(( 0xAA ^ 0xFF ))
0x55
$ printf '0x%X\n' $(( 0xAAA ^ 0xFFF ))
0x555
$ printf '0x%X\n' $(( 0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ^ 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF ))
0x5555555555555555
There are only 16 5's instead of 32 as expected from the size of the input.
My input will be text strings without the 0x.
E.g.
x=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
y=FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
printf '0x%X\n' $(( 0x$x ^ 0x$y ))