34 lines
639 B
Python
34 lines
639 B
Python
#!/usr/bin/env python3
|
|
from __future__ import annotations
|
|
|
|
import getpass
|
|
|
|
import bcrypt
|
|
|
|
|
|
def main() -> int:
|
|
first = getpass.getpass("Contraseña: ")
|
|
second = getpass.getpass("Repetir contraseña: ")
|
|
|
|
if first != second:
|
|
raise SystemExit(
|
|
"Las contraseñas no coinciden."
|
|
)
|
|
|
|
if len(first) < 12:
|
|
raise SystemExit(
|
|
"Use al menos 12 caracteres."
|
|
)
|
|
|
|
password_hash = bcrypt.hashpw(
|
|
first.encode("utf-8"),
|
|
bcrypt.gensalt(rounds=12),
|
|
).decode("utf-8")
|
|
|
|
print(password_hash)
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|