Skip to content

Instantly share code, notes, and snippets.

@AndrewFarley
Last active August 21, 2018 18:01
Show Gist options
  • Save AndrewFarley/2397c3e580c3a95b88e6171904b22ba0 to your computer and use it in GitHub Desktop.
Save AndrewFarley/2397c3e580c3a95b88e6171904b22ba0 to your computer and use it in GitHub Desktop.
import bcrypt
import hashlib
import time
import random
import string
from datetime import datetime, date
print("100 iterations of hashing")
print("=========================")
# Bcrypt
start = datetime.now().time()
x = 0
while x < 100:
randstring = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(14))
bcrypt.hashpw(randstring.encode('utf-8'), bcrypt.gensalt())
x = x + 1
end = datetime.now().time()
print("BCrypt: {}".format(datetime.combine(date.today(), end) - datetime.combine(date.today(), start)))
# SHA512
start = datetime.now().time()
x = 0
while x < 100:
randstring = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(14))
hashlib.sha512(randstring.encode('utf-8')).hexdigest()
x = x + 1
end = datetime.now().time()
print("sha512: {}".format(datetime.combine(date.today(), end) - datetime.combine(date.today(), start)))
print("=========================")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment