You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was hoping to see a speed increase from hashlib, but pycryptodome appears to be running ~6x slower that hashlib with SHA-512 generation...
python 3.7.1 (64bit) on windows 10 64-bit.
`from random import randint
import string
import timeit
import hashlib
builtin = """
import hashlib
import random
import string
max = 1024
randomString = "This is a test only a test, of the python string, going through this shite, to see if there is any performance difference between hashlib and a different library"
sha = hashlib.sha512()
sha.update(randomString.encode("utf-16"))
sha.hexdigest()
"""
pcrypto = """
from Crypto.Hash import SHA512
import random
import string
max = 1024
randomString = "This is a test only a test, of the python string, going through this shite, to see if there is any performance difference between hashlib and a different library"
sha = SHA512.new()
sha.update(randomString.encode("utf-16"))
sha.hexdigest()
"""
print ("hashlib - ",timeit.timeit(stmt=builtin, number=10000))
print ("PCrytpo - ",timeit.timeit(stmt=pcrypto, number=10000))
`
hashlib - 0.036552100000000004
PCrytpo - 0.4269634
Is this expected? I'm happy to work with you to diagnose this further...
I have code that is heavily utilizing SHA-512 hashes and if there is a faster way to generate them, I'm more than happy to put some effort in to assist.
The text was updated successfully, but these errors were encountered:
hashlib is backed by openssl, which implements SHA512 in assembly using AVX instructions (assuming you run a modern X86 CPU), so yes it is expected to be faster than PyCryptodome, which only uses portable C (with some SSE2 intrinsics here and there).
I was hoping to see a speed increase from hashlib, but pycryptodome appears to be running ~6x slower that hashlib with SHA-512 generation...
python 3.7.1 (64bit) on windows 10 64-bit.
`from random import randint
import string
import timeit
import hashlib
builtin = """
import hashlib
import random
import string
max = 1024
randomString = "This is a test only a test, of the python string, going through this shite, to see if there is any performance difference between hashlib and a different library"
sha = hashlib.sha512()
sha.update(randomString.encode("utf-16"))
sha.hexdigest()
"""
pcrypto = """
from Crypto.Hash import SHA512
import random
import string
max = 1024
randomString = "This is a test only a test, of the python string, going through this shite, to see if there is any performance difference between hashlib and a different library"
sha = SHA512.new()
sha.update(randomString.encode("utf-16"))
sha.hexdigest()
"""
print ("hashlib - ",timeit.timeit(stmt=builtin, number=10000))
print ("PCrytpo - ",timeit.timeit(stmt=pcrypto, number=10000))
`
hashlib - 0.036552100000000004
PCrytpo - 0.4269634
Is this expected? I'm happy to work with you to diagnose this further...
I have code that is heavily utilizing SHA-512 hashes and if there is a faster way to generate them, I'm more than happy to put some effort in to assist.
The text was updated successfully, but these errors were encountered: