L
L
Leksat2013-04-01 18:35:42
PHP
Leksat, 2013-04-01 18:35:42

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

4 answer(s)
H
Hint, 2013-04-01
@Leksat

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.

A
Alexey Zhurbitsky, 2013-04-01
@blo

Hash with a salt and concatenate that salt with the hash. You can take your example from stackoverflow as a basis.

V
Vidog, 2013-04-02
@Vidog

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.

T
TheMengzor, 2013-04-03
@TheMengzor

add salt or timestamp

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question