Last active
August 8, 2024 18:34
-
-
Save ilyaevseev/7592cc899841150bc11669f926234dc7 to your computer and use it in GitHub Desktop.
Generate bcrypt password for GLAuth
This file contains hidden or 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
#!/usr/bin/python3 | |
# apt install python3-bcrypt | |
import string | |
import random | |
import bcrypt | |
import sys | |
from getpass import getpass | |
passlen = 30 | |
letters = string.ascii_letters | |
if len(sys.argv) > 1: | |
plain = "".join(random.choice(letters) for i in range(passlen)) | |
echop = True | |
else: | |
print("Enter password:", end = " ") | |
plain = getpass() | |
echop = False | |
crypted = bcrypt.hashpw(plain.encode("utf-8"), bcrypt.gensalt()) | |
hexcrypt = "".join("{:02x}".format(c) for c in crypted) | |
print(plain) if echop else print("") | |
print(crypted.decode("utf-8")) | |
print(hexcrypt) | |
## END ## |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment