Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sample synchronous encrypt fails #3

Open
jhargis opened this issue Sep 20, 2014 · 0 comments
Open

sample synchronous encrypt fails #3

jhargis opened this issue Sep 20, 2014 · 0 comments

Comments

@jhargis
Copy link

jhargis commented Sep 20, 2014

Same error on linux python 2.7 and os x python 2.7

In [1]: from simplecrypto import encrypt, decrypt, AesKey

In [2]: # `encrypt` and `decrypt` use AES-256.

In [3]: m = encrypt('secret message', 'secret key')
---------------------------------------------------------------------------
UnicodeDecodeError                        Traceback (most recent call last)
<ipython-input-3-31706546d5a4> in <module>()
----> 1 m = encrypt('secret message', 'secret key')

/Library/Python/2.7/site-packages/simplecrypto/key.pyc in encrypt(message, key)
    192     Shortcut for AES256 base64 encryption with string or bytes key.
    193     """
--> 194     return AesKey(to_bytes(key)).encrypt(message)
    195
    196 def decrypt(encrypted_message, key):

/Library/Python/2.7/site-packages/simplecrypto/key.pyc in encrypt(self, message)
     60         the base64 encoded encrypted message.
     61         """
---> 62         return base64(self.encrypt_raw(to_bytes(message)))
     63
     64     def decrypt(self, encrypted_message):

/Library/Python/2.7/site-packages/simplecrypto/formats.pyc in to_base64(message)
     11     Returns the base64 representation of a string or bytes.
     12     """
---> 13     return b64encode(to_bytes(message)).decode('ascii')
     14
     15 def from_base64(message):

/Library/Python/2.7/site-packages/simplecrypto/formats.pyc in to_bytes(message)
     36     """
     37     if isinstance(message, str):
---> 38         return message.encode('utf-8')
     39     else:
     40         return bytes(message)

UnicodeDecodeError: 'ascii' codec can't decode byte 0x9c in position 0: ordinal not in range(128)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant