21 lines
677 B
Python
21 lines
677 B
Python
"""Produce a salted password verifier without putting plaintext in command arguments."""
|
|
|
|
import getpass
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "backend" / "src"))
|
|
from modelforge_api.services.operator_password import hash_password
|
|
|
|
if __name__ == "__main__":
|
|
password = (
|
|
getpass.getpass("Operator password: ")
|
|
if sys.stdin.isatty()
|
|
else sys.stdin.readline(4098).rstrip("\r\n")
|
|
)
|
|
try:
|
|
print(hash_password(password))
|
|
except (ValueError, UnicodeError):
|
|
print("Invalid password: enter 1 to 1024 characters.", file=sys.stderr)
|
|
raise SystemExit(2) from None
|