icapps / flutter_secure_file_storage

MIT License
8 stars 2 forks source link

Mismatch in encoding and decoding of String #2

Closed julemand101 closed 2 years ago

julemand101 commented 2 years ago

The code found in: https://github.com/icapps/flutter_secure_file_storage/blob/d0317a33cf51faeaf00fd465df934341979b52f1/lib/src/encryption_util.dart#L19-L27

Is problematic since string.codeUnits (used when encrypting) returns UTF-16 code units:

An unmodifiable list of the UTF-16 code units of this string.

https://api.dart.dev/stable/2.15.1/dart-core/String/codeUnits.html

While the decryption logic uses utf8.decode which is used to decode UTF-8.

You should use utf8.encode to encode your String if your intension is to use UTF-8.

ikbendewilliam commented 2 years ago

Hi, thanks for your ticket, this is indeed not correct. However we have a PR already open that refactors this and fixes it. Can you try to use that branch instead and see if everything works as expected?

ikbendewilliam commented 2 years ago

This is fixed in the latest release (0.0.2) since we reworked some of this logic.