in reply to Re^2: Generate a session ID
in thread Generate a session ID
This won't be speedy but you could use fewer rands by adapting your original approach.
print new_session_id(), $/; sub new_session_id { my $id = ''; for ( 1 .. 32 ) { $id .= sprintf "%x", rand(16); } return $id; }
You should also see if you've got Digest/Digest::MD5 available on your system. You can do something like:
use Digest::MD5 "md5_hex"; my @user_info = map { $ENV{$_} } grep { /USER|REMOTE/ } keys %ENV; print md5_hex( rand() . join('', @user_info) );
Don't forget to do a search for unique ID too, there are many points of departure: Google on the pen for "unique id." Also, try vanilla "unique."
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Generate a session ID
by Spidy (Chaplain) on Dec 05, 2005 at 02:30 UTC |