mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-18 12:09:12 +00:00
Use HMAC-based deterministic shuffle
This commit is contained in:
32
src/tests/test_password_shuffle_consistency.py
Normal file
32
src/tests/test_password_shuffle_consistency.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.append(str(Path(__file__).resolve().parents[1]))
|
||||
|
||||
from seedpass.core.password_generation import PasswordGenerator, PasswordPolicy
|
||||
|
||||
|
||||
class DummyEnc:
|
||||
def derive_seed_from_mnemonic(self, mnemonic):
|
||||
return b"\x00" * 32
|
||||
|
||||
|
||||
class DummyBIP85:
|
||||
def derive_entropy(self, index: int, bytes_len: int, app_no: int = 32) -> bytes:
|
||||
return bytes((index + i) % 256 for i in range(bytes_len))
|
||||
|
||||
|
||||
def make_generator():
|
||||
pg = PasswordGenerator.__new__(PasswordGenerator)
|
||||
pg.encryption_manager = DummyEnc()
|
||||
pg.bip85 = DummyBIP85()
|
||||
pg.policy = PasswordPolicy()
|
||||
return pg
|
||||
|
||||
|
||||
def test_password_generation_consistent_output():
|
||||
pg = make_generator()
|
||||
expected = "0j6R3e-%4xN@N{Jb"
|
||||
assert pg.generate_password(length=16, index=1) == expected
|
||||
# Generating again should produce the same password
|
||||
assert pg.generate_password(length=16, index=1) == expected
|
Reference in New Issue
Block a user