electron-store icon indicating copy to clipboard operation
electron-store copied to clipboard

wrong encryptionKey just overwrites the file?

Open vikasprogrammer opened this issue 6 years ago • 2 comments

I am doing this

store = new Store({
        name : 'encrypted_config',
        encryptionKey : 'test123',
});

When the app restarts and I try to do this

store = new Store({
        name : 'encrypted_config',
        encryptionKey : 'xyz123',
});

it just creates a new file instead of throwing error or something, am I missing something?

vikasprogrammer avatar Apr 25 '18 12:04 vikasprogrammer

Off the top of my head, in the readme, it is mentioned that

It also has the added bonus of ensuring the config file's integrity. If the file is changed in any way, the decryption will not work, in which case the store will just reset back to its default state.

I assume that since the key changed, such integrity check failed and the file was reset to the default state (and encrypted with a new key)

For me it makes sense, as in case of an error, firstly your application would not be usable anymore, secondly, you would want this file to be removed (as you don't remember the key anyway) and a new file to be created with a new key. The package does it for you.

I let somebody among the maintainers correct me if I am wrong.

UPDATE: similar discussion in #35

Spring3 avatar Jun 17 '18 23:06 Spring3

This is really bad intended behavior in my opinion. I'm not using this package, but it shouldn't be so easy to clear the data-store. It seems dangerous. I agree that it also shouldn't crash the application as mentioned in #35, but surely there is some more middle of the road solution.

Nantris avatar Jun 23 '18 01:06 Nantris