2
0
mirror of https://github.com/offen/website.git synced 2024-11-26 18:50:27 +01:00
website/accounts/scripts/hash.py

21 lines
513 B
Python
Raw Normal View History

2019-07-16 10:29:24 +02:00
import base64
import argparse
from passlib.hash import bcrypt
parser = argparse.ArgumentParser()
parser.add_argument("--password", type=str, help="The password to hash", required=True)
parser.add_argument(
"--plain",
help="Do not encode the result as base64",
default=False,
action="store_true",
)
if __name__ == "__main__":
args = parser.parse_args()
out = bcrypt.hash(args.password)
if not args.plain:
out = base64.standard_b64encode(out.encode()).decode()
print(out)