Ask Your Question
0

hexadecimal to binary

asked 2025-02-28 05:48:00 +0100

Kaunil gravatar image

I have two hexadecimal strings from Hexadecimal string monoid. I want to XOR them. As there is no XOR function inbuilt, I wish to convert them to binary.

S=BinaryStrings()
H=HexadecimalStrings()
A=H('4ac0')
B=H('b53f')
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2025-02-28 16:16:25 +0100

Max Alekseyev gravatar image

There is no need to convert to binary to perform XOR, converting to a numerical value is enough. For example,

H=HexadecimalStrings()
A=H('4ac0')
B=H('b53f')
hex( eval('0x'+str(A)) ^^ eval('0x'+str(B)) )

gives 0xffff. If element of H is needed, one can use

H( hex( eval('0x'+str(A)) ^^ eval('0x'+str(B)) )[2:] )
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2025-02-28 05:48:00 +0100

Seen: 93 times

Last updated: Feb 28