csquared / fernet.js

Javascript implementation of Fernet symmetric encryption https://github.com/kr/fernet-spec
MIT License
73 stars 29 forks source link

Malformed utf-8 error thrown when decrypting large tokens encrypted in Python #23

Open mraleson opened 1 year ago

mraleson commented 1 year ago

I encrypted some data using Fernet from Cryptography Python package. I was able to decrypt some short messages, but for larger messages I got a "Error: Malformed UTF-8 data" error raised from Object.stringify in crypto-js core.js.

As a workaround I had to abandon the fernet.js library and wrote a decrypt function myself. Its totally untested, but seems to decrypt. I tried to follow the pattern outlined in Python's implementation. For anyone else working around the same issue here is a gist with my node Fernet decrypt function

sinamics commented 1 year ago

Had the exact same issue when decrypting larger chunks.. your gist code worked perfectly.