longmne
longmne

Reputation: 13

How to Xor cipher_text and and hex value?

How do I use python to Xor cipher-text1 XOR cipher-text2 = "3c0d094c1f523808000d09" and "746865" to get this "48656c"? Thanks

It is based on this https://crypto.stackexchange.com/questions/59/taking-advantage-of-one-time-pad-key-reuse

enter image description here

Upvotes: 0

Views: 811

Answers (1)

Wander Nauta
Wander Nauta

Reputation: 19665

You can use the ^ bitwise exclusive or operator on each byte:

>>> a = bytes.fromhex('3c0d094c1f523808000d09')
>>> b = bytes.fromhex('746865')
>>> bytes(x ^ y for x, y in zip(a, b)).hex()
'48656c'

Upvotes: 1

Related Questions