summaryrefslogtreecommitdiff
path: root/pgpwordlist/funcs.py
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2016-12-31 22:02:21 +0200
committerLars Wirzenius <liw@liw.fi>2016-12-31 22:02:21 +0200
commit23683ca2bc1d9dd07e4ebee6ba348a5e7eaee1bb (patch)
treebe30ed4198375c1215117b5535776775502489a7 /pgpwordlist/funcs.py
parent9d4e2bf3432907d305839e731a22c2f4796c651d (diff)
downloadpy_pgpwordlist-23683ca2bc1d9dd07e4ebee6ba348a5e7eaee1bb.tar.gz
Add get_hex function to get hex from word
Diffstat (limited to 'pgpwordlist/funcs.py')
-rw-r--r--pgpwordlist/funcs.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/pgpwordlist/funcs.py b/pgpwordlist/funcs.py
index 59a5972..2801839 100644
--- a/pgpwordlist/funcs.py
+++ b/pgpwordlist/funcs.py
@@ -18,10 +18,18 @@
import pgpwordlist
+_words = pgpwordlist.pgp_word_list
+
def get_word(hex, offset):
hex = hex.lower()
- t = pgpwordlist.pgp_word_list.get(hex)
+ t = _words.get(hex)
if t is None:
raise KeyError(hex)
return t[offset % 2]
+
+
+def get_hex(word):
+ for hex, t in _words.items():
+ if word.lower() in t:
+ return hex.lower()