diff options
Diffstat (limited to 'pgpwordlist/funcs.py')
-rw-r--r-- | pgpwordlist/funcs.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/pgpwordlist/funcs.py b/pgpwordlist/funcs.py index 2801839..84d3d0d 100644 --- a/pgpwordlist/funcs.py +++ b/pgpwordlist/funcs.py @@ -33,3 +33,17 @@ def get_hex(word): for hex, t in _words.items(): if word.lower() in t: return hex.lower() + + +def hex_to_words(hexstr): + words = [get_word(hex, i) for i, hex in enumerate(_hex_bytes(hexstr))] + return ' '.join(words) + + +def _hex_bytes(hexstr): + for i in range(0, len(hexstr), 2): + yield hexstr[i:i+2] + + +def words_to_hex(wordstr): + return ''.join(get_hex(w) for w in wordstr.split()) |