1 |
## -------------------------------------------------------------------------------- |
2 |
## $Id$ |
3 |
## -------------------------------------------------------------------------------- |
4 |
## $Log$ |
5 |
## -------------------------------------------------------------------------------- |
6 |
|
7 |
|
8 |
|
9 |
# derived from: |
10 |
# CGI::Session::ID::MD5 - default CGI::Session ID driver |
11 |
# Id: MD5.pm,v 3.2 2002/11/27 12:30:26 sherzodr Exp |
12 |
# please visit http://search.cpan.org/src/SHERZODR/CGI-Session-3.11/Session/ID/MD5.pm |
13 |
|
14 |
package Data::UUID::PurePerl; |
15 |
|
16 |
# $Id$ |
17 |
|
18 |
use strict; |
19 |
use Digest::MD5; |
20 |
use vars qw($VERSION); |
21 |
|
22 |
($VERSION) = '$Revision: 3.2 $' =~ m/Revision:\s*(\S+)/; |
23 |
|
24 |
sub generate_id { |
25 |
#my $self = shift; |
26 |
|
27 |
my $md5 = new Digest::MD5(); |
28 |
$md5->add($$ , time() , rand(9999) ); |
29 |
|
30 |
return $md5->hexdigest(); |
31 |
} |
32 |
|
33 |
sub generate_id_blocks { |
34 |
my $count = shift; |
35 |
my @id; |
36 |
for (1..$count) { |
37 |
push @id, generate_id(); |
38 |
} |
39 |
my $id = join('-', @id); |
40 |
return $id; |
41 |
} |
42 |
|
43 |
1; |