I'm developing an electron application and when the user first starts the program, a random string is generated. This needs to then be persisted across sessions. This string is extremely important and cannot be lost.
I've been trying to think of both how to store this and the best place and method to store this string.
Here are some potential solutions I came up with:
Embed the string into the executable of the program.
- I don't know if this can be done after the program is already installed. Also if the user uninstalls the program it will be lost.
Store the string in a text file into the installation directory of the program.
- Decent, but a similar concern with the first option. While an uninstall process may be able to skip that file, I worry that a user might delete the directory afterwards and lose the file.
Store it in the OS-specific app-data folder.
- Probably the best thing I've considered so far.
Store it in the registry
- Not sure the support for this sort of operation cross-platform.
In addition to a lot of these, I was wondering about additional precautions I could take, but was unsure of the viability of them. Such as:
A combination of the above? Perhaps store it in multiple locations so that if the user accidentally deletes it from one, there is a backup?
Is it possible to make the file difficult to delete? That is, a cross-platform way to assign a file permissions such that it requires escalation to delete it so that the user doesn't accidentally delete it.
Is there anything else that can be done that I might be missing? Storing it online cannot be done.