Created
October 12, 2018 16:33
-
-
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
This file contains 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
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