diff --git a/src/highlevelcrypto.py b/src/highlevelcrypto.py index 551aa376..e0b86f35 100644 --- a/src/highlevelcrypto.py +++ b/src/highlevelcrypto.py @@ -85,7 +85,12 @@ def random_keys(): def deterministic_keys(passphrase, nonce): """Generate keys from *passphrase* and *nonce* (encoded as varint)""" - priv = hashlib.sha512(passphrase.encode() + nonce).digest()[:32] + if isinstance(passphrase, str): + ph = passphrase.encode() + else: + ph = passphrase + priv = hashlib.sha512(ph + nonce).digest()[:32] + pub = pointMult(priv) return priv, pub diff --git a/src/tests/test_randomtrackingdict.py b/src/tests/test_randomtrackingdict.py index 2db3c423..cbe0ee55 100644 --- a/src/tests/test_randomtrackingdict.py +++ b/src/tests/test_randomtrackingdict.py @@ -15,10 +15,10 @@ class TestRandomTrackingDict(unittest.TestCase): @staticmethod def randString(): """helper function for tests, generates a random string""" - retval = '' - for _ in range(32): - retval += chr(random.randint(0, 255)) - return retval + retval = bytearray(32) + for i in range(32): + retval[i] = random.randint(0, 255) + return bytes(retval) def test_check_randomtrackingdict(self): """Check the logic of RandomTrackingDict class"""