Skip to content

Instantly share code, notes, and snippets.

@alastairmccormack
Created July 3, 2019 20:06
Show Gist options
  • Save alastairmccormack/25195d81903e859637b9691f3f62ba22 to your computer and use it in GitHub Desktop.
Save alastairmccormack/25195d81903e859637b9691f3f62ba22 to your computer and use it in GitHub Desktop.
A Python implementation of Spring Security StandardPasswordEncoder
import hashlib
import binascii
password_salthash_hex = '916b8cb7de146eab16c83ac3e7cdd33751a4cb19dced8da5aab38d94ebebcff968ca5099cfccf28d'
password_salthash = binascii.a2b_hex(password_salthash_hex)
password_hash = password_salthash[8:]
password_salt = password_salthash[:8]
password = b'11111'
new_clear = password_salt + password
new_hash = new_clear
for x in range(1024):
new_hash = hashlib.new('sha256', new_hash).digest()
print(new_hash == password_hash)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment