Skip to content

Instantly share code, notes, and snippets.

@ichihara-3
Created October 12, 2018 16:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ichihara-3/6eba59a941f39fbcfe3d860589bf0be5 to your computer and use it in GitHub Desktop.
Save ichihara-3/6eba59a941f39fbcfe3d860589bf0be5 to your computer and use it in GitHub Desktop.
to check the results of sha256() in hashlib and pycrypto are same
from hashlib import sha256
from Crypto.Hash import SHA256
from os import urandom
count = 0
while True:
value = urandom(20)
crypt = SHA256.new()
crypt.update(value)
assert crypt.hexdigest() == sha256(value).hexdigest()
count += 1
if count % 10000 == 0:
print('count:', count, '\r', end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment