Skip to content

Allow to en/decrypt bytes #11

@dwt

Description

@dwt

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.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions