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

Stream decrypt error #24

Open
arcsector opened this issue Oct 18, 2018 · 0 comments
Open

Stream decrypt error #24

arcsector opened this issue Oct 18, 2018 · 0 comments

Comments

@arcsector
Copy link

Hello, I have been using pyaes for some time now, but I keep getting this error now when using decrypt_stream:

from pyaes import AESModeOfOperationCTR as ctr, encrypt_stream as es, decrypt_stream as ds
from yaml import load

credsdict = load(open("secrets.yml", 'r'))
key = credsdict['key'].encode('utf-8')
aes = ctr(key)
with open("secrets.yml", 'r') as file_in:
        with open('newsecrets','wb+') as file_out:
                es(aes, file_in, file_out)

newaes=ctr(key)
with open("newsecrets", 'r') as file_in:
        with open('newsecrets.yml', 'w+') as file_out:
                ds(newaes, file_in, file_out)
newdict = load(open('newsecrets.yml', 'r'))

It fails on the decryption with the following stack trace:

Traceback (most recent call last):
  File "createsecrets.py", line 28, in <module>
    ds(newaes, file_in, file_out)
  File "/usr/lib/python3.4/site-packages/pyaes/blockfeeder.py", line 227, in decrypt_stream
    _feed_stream(decrypter, in_stream, out_stream, block_size)
  File "/usr/lib/python3.4/site-packages/pyaes/blockfeeder.py", line 207, in _feed_stream
    chunk = in_stream.read(block_size)
  File "/usr/lib64/python3.4/codecs.py", line 319, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 1: invalid start byte

Any tips? I've dealt with Unicode errors before but I can't seem to get this one to work...

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