X-Git-Url: http://git.datanom.net/securemail.git/blobdiff_plain/3e18b00b2002d8269bc09c33e510bb4c89311cb4..b49f84de2e0655566790f5f11a8ef15ac379b8b3:/cryptonize.py diff --git a/cryptonize.py b/cryptonize.py index 9c1b02f..7a598d3 100644 --- a/cryptonize.py +++ b/cryptonize.py @@ -50,6 +50,8 @@ class Cryptonize: return plain def asymmetric_encrypt(self, privkey, pubkey, plain): + if not isinstance(plain, bytes): + plain = plain.encode('utf-8') box = Box(privkey, pubkey) if NACL_VERSION < "1.1.0": nonce = random(Box.NONCE_SIZE) @@ -61,6 +63,8 @@ class Cryptonize: return cipher def asymmetric_decrypt(self, privkey, pubkey, cipher): + if not isinstance(cipher, bytes): + cipher = cipher.encode('utf-8') box = Box(privkey, pubkey) plain = box.decrypt(cipher) box = None