Created
February 13, 2017 18:19
-
-
Save AndyNovo/73cce5360495be0b7a307d7a857c050f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import binascii, hashlib | |
k = "secretkey" | |
msg = "forge this punks" | |
kplus = k + "\x00"*(64-len(k)) | |
ipad = "\x36"*64 | |
opad = "\x5C"*64 | |
def XOR(raw1, raw2): | |
return binascii.unhexlify(format(int(binascii.hexlify(raw1), 16) ^ int(binascii.hexlify(raw2), 16), 'x')) | |
tag = hashlib.sha256(XOR(kplus, opad) + hashlib.sha256(XOR(kplus, ipad) + msg).digest()).digest() | |
print binascii.hexlify(tag) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment