-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/demichie/elicipy
- Loading branch information
Showing
1 changed file
with
19 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()) |