cryptr
cryptr copied to clipboard
Unable to try different secrets from user input
Hi,
I am building a small script which will take a secret from the user, and validate that it was correct before attempting to decrypt the main data.
To do this I need to be able to try a secret that may not be the correct one, attempt to decrypt a pre encrypted string that will result in a known value, and it will only result in the correct check string if the secret is right.
If at any point I instantiate a second instance of Cryptr (for example if the user gets it wrong), the program crashes with “Unable to read options file: Cannot read properties of undefined (reading decrypt)”. This means once I instantiate a Cryptr instance with one secret, it is then impossible for me to ever use a different secret.
There is a test for multiple instances of cryptr: https://github.com/MauriceButler/cryptr/blob/master/tests/index.js#L34
If you can write a failing test for this issue, send a PR and I'll look at it.