Answer the question
In order to leave comments, you need to log in
Two way dynamic hash for user_id?
I don’t understand how to formulate the question in one line, otherwise I would have googled already :)
There is a user_id - integer. I will pass it through javascript to collect statistics. But you can't shine it.
I need the user_id to be passed by hash each time, but different each time . Moreover, it is necessary that the hash can be turned back into the original number.
Here is a simple recipe - stackoverflow.com/a/9262137
But the hash for one value, of course, is always the same.
Actually the question is: is it possible what I want?
(I guess not, but you never know...)
Answer the question
In order to leave comments, you need to log in
Hashing is an irreversible operation. In this case, encryption is required. To make the result different, just add a salt to the id.
As a result, we take id (for example, 12345), add a random string (12345-z3F4g) to it, and encrypt.
Hash with a salt and concatenate that salt with the hash. You can take your example from stackoverflow as a basis.
You can store both the id and the hash in the database, then they simply pass the hash to you, and you look for the id by it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question