Ask coding questions

← Back to all posts
Cryptography Invalid Token
pieninja

So I try to save some data using a cryptography key, and it encrypts fine, but when i try to decrypt it (using the same key) it fails! The key is stored as a repl environmental variable thing. Why is it failing? To test it yourself, at the start put n, then put 5, then sa, then s, then y, and then a username and password, do the same thing but go to load, and put the same username and password, it should say invalid token.

Voters
pieninja
Comments
hotnewtop
Spacecraft

Maybe I'm just not looking in the right place, but I don't see anywhere in your code where you define the environmental variable filekey. When I run your code, it's trying to find this value, but it doesn't exist since the code doesn't define it. Add your variable using this:

To summarize - I can't get to the username/password creation because the code fails before that, since filekey is not defined in my environmental variables.

pieninja

@Spacecraft oh, i thought the repl environmental stuff would work for everyone. ok, ill fix that and try to find another way