Skip to content

Instantly share code, notes, and snippets.

@markddavidoff
Created May 14, 2021 03:00
Show Gist options
  • Select an option

  • Save markddavidoff/01a76d6f3c42d7497d6be4faa59cbfcb to your computer and use it in GitHub Desktop.

Select an option

Save markddavidoff/01a76d6f3c42d7497d6be4faa59cbfcb to your computer and use it in GitHub Desktop.

Revisions

  1. markddavidoff created this gist May 14, 2021.
    11 changes: 11 additions & 0 deletions hmac_collision.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    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'