Files
Passgeny/tests/test_phogen.py
Mitja HORVAT bcae51ead9 c,python: Use little-endina byte order for bigint arithmetics
This better matches what one would expect from the hex or base64
(upcoming) formats.
2021-11-15 01:13:17 +01:00

28 lines
704 B
Python
Executable File

#!/usr/bin/env python3
import hashlib
from passgeny import phogen
from passgeny import bhash
PHO_GEN_TEST = [
[ b"passgeny", "vatome iddeda pashis artarc" ],
[ b"phonetic", "joredl qibini kninet ouslis" ],
[ b"generator", "vormul zilyth disedl chryso" ],
[ b"password", "wompot ficara uplort lancon" ],
[ b"duck", "inerea iricin ovusia irrisi" ] ]
for pt in PHO_GEN_TEST:
bh = bhash.Bhash()
bh.from_bytes(hashlib.sha256(pt[0]).digest())
wa = []
for x in range(4):
wa.append(phogen.encode(bh, 6))
word = " ".join(wa)
if word != pt[1]:
raise Exception("Test failed: {} != {}".format(word, pt1))
print(word)