Thread SID zufall (5 answers)
Opened by styx-cc at 2007-08-16 20:58

styx-cc
 2007-08-17 03:34
#98301 #98301
User since
2006-05-20
533 Artikel
BenutzerIn

user image
Hab das mal getestet, scheint rel. zufaellig zu sein.
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/perl -w
use strict;
use Digest::MD5 qw/md5_hex/;

my @sessions;
push(@sessions, 'xyz') for (0..1);
for (0..999999) {
push(@sessions, create_sid());
}

my %double;
for my $key (@sessions) {
$double{$key}++;
}

for my $key (keys %double) {
print "$key: $double{$key}\n" if ($double{$key}>1) ;
}

sub create_sid {
my $sid;
#create a random SID
$sid = rand(20)*rand(20);
#my $time = time();
$sid .= time/(int(rand(10)+1));
#print "$sid";
$sid = md5_hex($sid);
return $sid;
}


MfG
Pörl.

View full thread SID zufall