diff --git a/generate_hash.py b/generate_hash.py index 0182e90..858ae76 100644 --- a/generate_hash.py +++ b/generate_hash.py @@ -1,6 +1,22 @@ import bcrypt +import getpass -password = "xxxxx" # original password -hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt()) # geberate hash +def get_password(): + """Ask the user for a password twice and ensure they match.""" + while True: + password1 = getpass.getpass("Enter your password: ") + password2 = getpass.getpass("Confirm your password: ") -print(hashed.decode()) # copy this to the .env file + if password1 == password2: + return password1 # Return the valid password + else: + print("Error: Passwords do not match. Please try again.\n") + +# Get the password from the user +password = get_password() + +# Generate the hashed password +hashed = bcrypt.hashpw(password.encode(), bcrypt.gensalt()) + +print("\nYour hashed password (store this in .env or secrets.toml):") +print(hashed.decode())