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

Allow to en/decrypt bytes #11

Open
dwt opened this issue Mar 24, 2021 · 2 comments
Open

Allow to en/decrypt bytes #11

dwt opened this issue Mar 24, 2021 · 2 comments
Assignees

Comments

@dwt
Copy link

dwt commented Mar 24, 2021

Hi there,

while trying to use this project, I've stumbled on the issue that it is not possible to use RNCryptor to en-/decrypt bytes().

Specifically here the result is always cast to str().

My workaround was to define a custom subclass that patches out this to_str() call like this:

class BytesCrypter(rncryptor.RNCryptor):
    def post_decrypt_data(self, data):
        # super call normalizes return value to str() which breaks us
        data = data[:-rncryptor.bord(data[-1])]
        return data

Since encrypt() already supports byte data, it would be very helpful if decrypt() could support that too. I'd imagine that could be achieved ether with a keyword (only) argument like this:

def decrypt(self, data, password, post_process=to_str):
    # ...

I would like the encryption interface to work solely on bytes if possible, especially on python 3 as that would be much more uniiversal, but I'm not sure if that api breakage would be ok - hence the post_process argument idea.

@rnapier
Copy link
Member

rnapier commented Mar 24, 2021

See #8, but I believe we should be able to release a fix to this as long as we bump the major version number (i.e. following PEP 440).

@ykalchevskiy, are you still maintaining this repo, or would you prefer I look at it?

@dwt
Copy link
Author

dwt commented Mar 24, 2021

:-) Well, what you recommend there, is actually exactly what I did. :-)

Looking forward to your fix!

@rnapier rnapier self-assigned this Mar 24, 2021
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

2 participants