def add_hex_mod(hexstr1, hexstr2): pt = str.split(hexstr1) sk = str.split(hexstr2) for x in range(0, len(pt)): hex1 = '0x' + pt[x] hex2 = '0x' + sk[x] # convert them to integers, add them, and modulo the answer by 2^64 to get it back into a 16 char hex print hex((int(hex1, 16) + int(hex2, 16)) % (2 ** 64)) # first param is the plaintext, separated by spaces into 64 bit chunks # second param is the subkey, separated by spaces into 64 bit chunks add_hex_mod('9f775a65c0e3811c c8bca15acf7a08ae 6e754a871451004c 35de95360e00810f', '0df6f4748765b209 dacbad80a1da643c 4d13bd990627c2ea 37ad1891e93add66')
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question