Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't save string when the value is empty #3

Closed
Mingyueyixi opened this issue Mar 1, 2024 · 3 comments
Closed

Can't save string when the value is empty #3

Mingyueyixi opened this issue Mar 1, 2024 · 3 comments

Comments

@Mingyueyixi
Copy link
Contributor

hi,
When i save data with a empty string, It will throw Exception.

The code is:

EncryptedSharedPreferences.getInstance().setString("abc", "");

The Exception is:

E/flutter (26499): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: RangeError (start): Invalid value: Only valid value is 0: -16
E/flutter (26499): #0 RangeError.checkValidRange (dart:core/errors.dart:360:7)
E/flutter (26499): #1 _TypedIntListMixin.sublist (dart:typed_data-patch/typed_data_patch.dart:466:31)
E/flutter (26499): #2 PaddedBlockCipherImpl.doFinal (package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart:87:64)
E/flutter (26499): #3 PaddedBlockCipherImpl.process (package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart:74:25)
E/flutter (26499): #4 AES.encrypt (package:encrypt/src/algorithms/aes.dart:38:32)
E/flutter (26499): #5 Encrypter.encryptBytes (package:encrypt/src/encrypter.dart:12:19)
E/flutter (26499): #6 Encrypter.encrypt (package:encrypt/src/encrypter.dart:20:12)
E/flutter (26499): #7 AESEncryptor.encrypt (package:encrypt_shared_preferences/src/crypto/aes.dart:14:46)
E/flutter (26499): #8 SharedPreferencesDecorator.save (package:encrypt_shared_preferences/src/shared_preferences_decorator.dart:155:22)
E/flutter (26499): #9 SharedPreferencesDecorator.setString (package:encrypt_shared_preferences/src/shared_preferences_decorator.dart:148:12)
E/flutter (26499): #10 EncryptedSharedPreferences.setString (package:encrypt_shared_preferences/src/enc_shared_pref.dart:66:23)

@xaldarof
Copy link
Owner

xaldarof commented Mar 2, 2024

Hi, can u provide MRE?

@Mingyueyixi
Copy link
Contributor Author

Last week my project used a temporary solution where the empty string was saved with the key removed instead of stored.

Maybe that's probably not a good idea, and the other way is not encrypty the empty string,
but I'm in the country this weekend, and I can't verify it.

Sorry about that

@xaldarof
Copy link
Owner

xaldarof commented Mar 2, 2024

Great, send me the MRE when it is possible. Good luck. I will close the issue if you can send me the MRE; I can reopen the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants