Re: get hexadecimal hash string for a number
On 9/18/2012 1:10 PM, Lew wrote:
Magnus Warker wrote:
I want users to register on a site and send confirmation emails to them.
These emails should contain a link like this:
http://myurl?registration=E4AC4BD4
Here, "E4AC4BD4" should be a unique string. My idea for such a string is
just to hash an integer, i. e. the internal database key for the
registration record.
However, I actually don't know how to get such a hash. I tried BCrypt,
but this produces hashes built out of characters that I would not want
to be in a URL, e. g. commatas and that.
I would like to have a string like this:
- hexadecimal only
- fixed size, e. g. always n characters, independend of the integer
Can you help?
First of all, hashing a unique integer is silly. It's already unique!
If you have a reliably unique, stable integer ID, you don't need to hash it!
Just use the value.
The real issue for the confirmation link problem is not
uniqueness but that it has to be hard to guess.
Which changes the solution quite a bit.
Arne