summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pgpwordlist/funcs.py14
-rw-r--r--pgpwordlist/funcs_tests.py22
2 files changed, 18 insertions, 18 deletions
diff --git a/pgpwordlist/funcs.py b/pgpwordlist/funcs.py
index 84d3d0d..4e11b9f 100644
--- a/pgpwordlist/funcs.py
+++ b/pgpwordlist/funcs.py
@@ -21,22 +21,22 @@ import pgpwordlist
_words = pgpwordlist.pgp_word_list
-def get_word(hex, offset):
- hex = hex.lower()
- t = _words.get(hex)
+def get_word(hexstr, offset):
+ hexstr = hexstr.lower()
+ t = _words.get(hexstr)
if t is None:
- raise KeyError(hex)
+ raise KeyError(hexstr)
return t[offset % 2]
def get_hex(word):
- for hex, t in _words.items():
+ for hexstr, t in _words.items():
if word.lower() in t:
- return hex.lower()
+ return hexstr.lower()
def hex_to_words(hexstr):
- words = [get_word(hex, i) for i, hex in enumerate(_hex_bytes(hexstr))]
+ words = [get_word(h, i) for i, h in enumerate(_hex_bytes(hexstr))]
return ' '.join(words)
diff --git a/pgpwordlist/funcs_tests.py b/pgpwordlist/funcs_tests.py
index 5473ac8..2697e43 100644
--- a/pgpwordlist/funcs_tests.py
+++ b/pgpwordlist/funcs_tests.py
@@ -31,9 +31,9 @@ class WordListQueriesTests(unittest.TestCase):
even_words = set()
odd_words = set()
for i in range(256):
- hex = '%02x' % i
- even_word = pgpwordlist.get_word(hex, 0)
- odd_word = pgpwordlist.get_word(hex, 1)
+ hexstr = '%02x' % i
+ even_word = pgpwordlist.get_word(hexstr, 0)
+ odd_word = pgpwordlist.get_word(hexstr, 1)
self.assertNotIn(even_word, even_words)
self.assertNotIn(odd_word, odd_words)
even_words.add(even_word)
@@ -41,16 +41,16 @@ class WordListQueriesTests(unittest.TestCase):
def test_round_trip_works(self):
for i in range(256):
- hex = '%02x' % i
- even_word = pgpwordlist.get_word(hex, 0)
- odd_word = pgpwordlist.get_word(hex, 1)
- self.assertEqual(pgpwordlist.get_hex(even_word), hex)
- self.assertEqual(pgpwordlist.get_hex(odd_word), hex)
+ hexstr = '%02x' % i
+ even_word = pgpwordlist.get_word(hexstr, 0)
+ odd_word = pgpwordlist.get_word(hexstr, 1)
+ self.assertEqual(pgpwordlist.get_hex(even_word), hexstr)
+ self.assertEqual(pgpwordlist.get_hex(odd_word), hexstr)
class WordStringTests(unittest.TestCase):
def test_roundtrip_works(self):
- hex = 'cafef00d'
- words = pgpwordlist.hex_to_words(hex)
- self.assertEqual(pgpwordlist.words_to_hex(words), hex)
+ hexstr = 'cafef00d'
+ words = pgpwordlist.hex_to_words(hexstr)
+ self.assertEqual(pgpwordlist.words_to_hex(words), hexstr)