isar / hive

Lightweight and blazing fast key-value database written in pure Dart.
Apache License 2.0
3.97k stars 393 forks source link

Data disappears from encrypted box once it is opened without cypher #1283

Open ig-garcia opened 3 months ago

ig-garcia commented 3 months ago

I did a test project with only Dart (no platforms) and this happened:

I opened an encrypted box and stored some values, then next time I opened the box without encryption and when I check the box.values they are empty.

Is this expected in any way? How can I check if my box is encrypted? I was expecting that I could check whether the db is encrypted by getting some garbage data. Even if I open the box with encryption again, it is always empty after first time.

kaciula commented 1 month ago

I think some of my users are experiencing an issue related to this. Once the user is logged in, I store the credentials in an encrypted box and every time the app is started from zero, I check if the credentials exist to know if the user is logged in or not.

On occasion, some users discover that they have been automatically logged out and I discovered that the cause of this is that the credentials disappeared from the encrypted box. But I'm never opening the box without encryption or doing anything to the encrypted box apart from saving the credentials.

And I have reports for 2 separate apps but only on iOS and only in the past month. I'm thinking that maybe the latest iOS system touches somehow the file with the encrypted box and that's why the data disappears. I can't seem to figure this out and I can't reproduce it.

Screenshot 2024-05-22 at 13 35 04