Fix line-breaks in Crypto.py

This commit is contained in:
Ben 2019-04-11 01:14:01 +01:00
parent e3ded3e5ce
commit ac28544351

View File

@ -1 +1,34 @@
import hashlib import secrets import string _alphabet = string.ascii_letters + string.digits class Crypto: @staticmethod def hash(undigested): return hashlib.md5(undigested.encode('utf-8')).hexdigest() @staticmethod def generate_random_key(): return ''.join(secrets.choice(_alphabet) for _ in range(16)) @staticmethod def encrypt_password(password, digest=True): if digest: password = Crypto.hash(password) swapped_hash = password[16:32] + password[0:16] return swapped_hash @staticmethod def get_login_hash(password, rndk): key = Crypto.encrypt_password(password, False) key += rndk key += 'Y(02.>\'H}t":E1' login_hash = Crypto.encrypt_password(key) return login_hash import hashlib
import secrets
import string
_alphabet = string.ascii_letters + string.digits
class Crypto:
@staticmethod
def hash(undigested):
return hashlib.md5(undigested.encode('utf-8')).hexdigest()
@staticmethod
def generate_random_key():
return ''.join(secrets.choice(_alphabet) for _ in range(16))
@staticmethod
def encrypt_password(password, digest=True):
if digest:
password = Crypto.hash(password)
swapped_hash = password[16:32] + password[0:16]
return swapped_hash
@staticmethod
def get_login_hash(password, rndk):
key = Crypto.encrypt_password(password, False)
key += rndk
key += 'Y(02.>\'H}t":E1'
login_hash = Crypto.encrypt_password(key)
return login_hash