Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
demichie committed Jan 21, 2025
2 parents 171b8e1 + e1b6c14 commit 9647dda
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions generate_hash.py
Original file line number Diff line number Diff line change
@@ -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())

0 comments on commit 9647dda

Please sign in to comment.