I am currently making a Python game where the user's high score gets encrypted and stored in a log (a text file). The reason for this encryption is because I don't want the user to be able to enter something (say, 1000000) into the text file. Is there a function that, given a string, will generate a string that looks random to the user (but it's not), and unlike a hash function, can be reversible? Does anyone know how to make one of these in Python? Thanks!
Asked
Active
Viewed 313 times
1 Answers
1
While not reversible, HMAC seem to be a plausible solution.
HMAC is a construct that adds a "key" to the hash digest, your program generates it with a symmetric key that's somewhat hidden in your program. You verify the player's scores by hashing the score with the key and compare the digest - this is a very typical tag comparison of message authentication code.
DannyNiu
- 10,640
- 2
- 27
- 64