firstfloorsoftware / flutter_sodium

Flutter bindings for libsodium
BSD 3-Clause "New" or "Revised" License
102 stars 46 forks source link

FormatException: Bad UTF-8 encoding 0x4f (at offset 1) #20

Closed imaNNeo closed 4 years ago

imaNNeo commented 4 years ago

Hi, we've tried to use SealedBox.sealOpen(cipher, keyPair), but Unfortunately we faced an exception. I checked the implementation and I realized you are forcing it to decode as UTF-8, and I think as we working with keys, and there are no special characters, and it is okay to decode it as ASCII. I had to copy your code and change it to solve my issue. UTF-8 decode should be optional. Thanks

kozw commented 4 years ago

Good feedback. You probably want to use SealedBox.sealBytesOpen, and decode the resulting bytes yourself. The SealedBox seal and sealOpen use utf8 encoding by design. I'm aware that the API isn't super clear, SealedBox.sealOpenUtf8 might be a better name.

imaNNeo commented 4 years ago

Thanks for your response. SealedBox.sealBytesOpen solved the problem. Great work!