Skip to content
Advertisement

Unpickling and decrypting a file in memory in Python 3.7

I have a pickled .pkl file that I encrypted using the following encrpytion:

JavaScript

I now want to decrypt and unpickle the file in memory. This is because I don’t want to alter the actual file in the storage.

I tried the following:

JavaScript

The original file is written as a pickled .pkl and then encrypted.

So I figured I could just load the file in Python, decrypt it and then unpickle it. Unfortunately I get the following error and I’m not sure how to fix it:

JavaScript

Advertisement

Answer

Use pickle.loads():

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement