28 lines
932 B
Python
28 lines
932 B
Python
import cryptography.fernet
|
|
import argon2
|
|
import base64
|
|
import random
|
|
|
|
# def encrypt_data(data_bytes, password, salt):
|
|
# password_hash = argon2.argon2_hash(password=password, salt=salt)
|
|
# encoded_hash = base64.urlsafe_b64encode(password_hash[:32])
|
|
# encryptor = cryptography.fernet.Fernet(encoded_hash)
|
|
# return encryptor.encrypt(data_bytes)
|
|
#
|
|
#
|
|
# def decrypt_data(cipher_bytes, password, salt):
|
|
# password_hash = argon2.argon2_hash(password=password, salt=salt)
|
|
# encoded_hash = base64.urlsafe_b64encode(password_hash[:32])
|
|
# decryptor = cryptography.fernet.Fernet(encoded_hash)
|
|
# return decryptor.decrypt(cipher_bytes)
|
|
|
|
import bcrypt
|
|
from getpass import getpass
|
|
master_secret_key = getpass('tell me the master secret key you are going to use')
|
|
salt = bcrypt.gensalt()
|
|
combo_password = "1234'".encode('utf-8') + salt + master_secret_key
|
|
hashed_password = bcrypt.hashpw(combo_password, salt)
|
|
|
|
|
|
bcrypt
|