Login, user in datenbank und encryption key
This commit is contained in:
@@ -2,7 +2,11 @@
|
||||
from Crypto.Cipher import AES
|
||||
from base64 import b64encode, b64decode
|
||||
import platform
|
||||
from Crypto.Hash import SHA256
|
||||
from Crypto.Hash import SHA256, SHA3_512
|
||||
from Crypto.Protocol.KDF import PBKDF2
|
||||
from Crypto.Random import get_random_bytes
|
||||
import random
|
||||
import string
|
||||
|
||||
|
||||
class Vermasseln:
|
||||
@@ -42,6 +46,18 @@ class Vermasseln:
|
||||
cipher = AES.new(hashed, AES.MODE_SIV, nonce = nonce)
|
||||
return cipher
|
||||
|
||||
@classmethod
|
||||
def userPasswordHash(self, password):
|
||||
|
||||
salt = "".join(random.choice(string.ascii_letters + string.digits) for i in range (32))
|
||||
hash_pw = (salt + password).encode("utf-8")
|
||||
h_obj = SHA3_512.new(hash_pw)
|
||||
password = salt + "$" + h_obj.hexdigest()
|
||||
|
||||
return password
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user