Skip to content

Instantly share code, notes, and snippets.

@markddavidoff
Created May 14, 2021 03:00
Show Gist options
  • Save markddavidoff/01a76d6f3c42d7497d6be4faa59cbfcb to your computer and use it in GitHub Desktop.
Save markddavidoff/01a76d6f3c42d7497d6be4faa59cbfcb to your computer and use it in GitHub Desktop.
hmac key collision
import hashlib
import hmac
string1 = 'plnlrtfpijpuhqylxbgqiiyipieyxvfsavzgxbbcfusqkozwpngsyejqlmjsytrmd'
string2 = 'eBkXQTfuBqp\'cTcar&g*'
key1 = hashlib.pbkdf2_hmac('sha1', string1.encode(), b'salt', 100000)
key2 = hashlib.pbkdf2_hmac('sha1', string2.encode(), b'salt', 100000)
hmac.new(key1, b"test", hashlib.sha256).hexdigest()
# '8122f91c70f4ac2205fc2039fc27bac3d54ccd91ee5ebf8d58fe13b406abd34a'
hmac.new(key2, b"test", hashlib.sha256).hexdigest()
# '8122f91c70f4ac2205fc2039fc27bac3d54ccd91ee5ebf8d58fe13b406abd34a'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment