use strict; use Digest::MD5; use Sys::Hostname; sub md5sid { my $hostname = hostname(); my $serial = new Digest::MD5; $serial->add($hostname); # Having the time in hex form is useful $serial->add(sprintf "%X", time()); # This is sort of slow, but strong. Reducing # the param for rand() will speed things, but # make collisions more likely. for (my $i=1; $i < rand(2345678); $i++ ) { $serial->add(chr(int(rand(223))+32)); } my $session = $serial->hexdigest(); return $session; }#-sub md5sid #### use Data::UUID; use constant IDGenerator => Data::UUID->new(); sub new_sid { IDGenerator->create() }