in reply to MD5-based Unique Session ID Generator
I would think hostname is a pretty hefty operation for genarating a session id, I'm not sure but I think it does a DNS lookup.
The ID is based on hostname, time, and some psuedo-random data. I've run a test with this to generate 50,000 IDs as fast as possible and check for collisions -- I didn't get any.
I use this for session ids (which I took from one of the Apache::Session modules)
I ran it within the same process over 100,000 times with no collisions.use Digest::MD5; $session_id = substr(md5_hex(md5_hex(time() . {} . rand() . $$)), 0, 3 +2);
This is sort of slow, but strong. Reducing the param for rand() will speed things, but make collisions more likely.
I am no crypto expert, but from what I know, Its not really any stronger than if you didn't do it this way. Using MD5 and different text each time, it is highly unlikely that you will find a collision actually, that is just the nature of MD5 and hashing algorithms in general.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: MD5-based Unique Session ID Generator
by pelagic (Priest) on Aug 19, 2004 at 15:09 UTC | |
by stvn (Monsignor) on Aug 19, 2004 at 15:29 UTC | |
by ctilmes (Vicar) on Aug 19, 2004 at 20:01 UTC | |
by ctilmes (Vicar) on Aug 20, 2004 at 12:12 UTC | |
by radiantmatrix (Parson) on Aug 19, 2004 at 20:37 UTC | |
by pelagic (Priest) on Aug 19, 2004 at 20:56 UTC | |
by stvn (Monsignor) on Aug 19, 2004 at 22:11 UTC | |
|
Re^2: MD5-based Unique Session ID Generator
by radiantmatrix (Parson) on Aug 19, 2004 at 20:31 UTC | |
by stvn (Monsignor) on Aug 19, 2004 at 22:19 UTC |