first commit

This commit is contained in:
2025-11-13 13:41:29 +00:00
parent c85c68f859
commit eb552a9164
10 changed files with 65 additions and 6 deletions

View File

@@ -9,3 +9,33 @@ def test_main_verify_round_trip() -> None:
salt, hashed = hash_password("secret-value")
assert main(["verify", "secret-value", salt, hashed]) == 0
assert main(["verify", "wrong", salt, hashed]) == 1
def test_main_hash_with_algorithm_pbkdf2() -> None:
"""Test hash command with --algorithm pbkdf2."""
assert main(["hash", "--algorithm", "pbkdf2", "test-password"]) == 0
def test_main_hash_with_algorithm_argon2() -> None:
"""Test hash command with --algorithm argon2."""
assert main(["hash", "--algorithm", "argon2", "test-password"]) == 0
def test_main_hash_with_algorithm_bcrypt() -> None:
"""Test hash command with --algorithm bcrypt."""
assert main(["hash", "--algorithm", "bcrypt", "test-password"]) == 0
def test_main_verify_with_algorithm() -> None:
"""Test verify command with --algorithm option."""
# Test with each algorithm
for algo in ["pbkdf2", "argon2", "bcrypt"]:
salt, hashed = hash_password("test-pw", algorithm=algo)
assert main(["verify", "--algorithm", algo, "test-pw", salt, hashed]) == 0
assert main(["verify", "--algorithm", algo, "wrong", salt, hashed]) == 1
def test_main_hash_algorithm_shortcut() -> None:
"""Test shortcut syntax with --algorithm option."""
# Should support: python3 salt.py --algorithm argon2 mypassword
assert main(["--algorithm", "argon2", "test-password"]) == 0