Files
Passgeny/tests/test_phogen.py
Mitja HORVAT ea5abfe149 python: Implement phogen encode
Implement phogen.encode() to encode Bhashes to phogen strings. This
commit also adds unit tests for the above function.
2021-11-09 19:26:03 +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", "herang xiasem zitend qibele" ],
[ b"phonetic", "lineum foneum zybale mangur" ],
[ b"generator", "latole elitab ackina exprou" ],
[ b"password", "nulize nomere fonici crednt" ],
[ b"duck", "catabb rompor cricin prunsi" ] ]
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)