line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Archive::Rgssad::Keygen; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
609
|
use Exporter 'import'; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
185
|
|
4
|
|
|
|
|
|
|
our @EXPORT_OK = qw(keygen); |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
82
|
use 5.010; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
154
|
|
7
|
4
|
|
|
4
|
|
26
|
use strict; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
147
|
|
8
|
4
|
|
|
4
|
|
19
|
use warnings FATAL => 'all'; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
256
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Archive::Rgssad::Keygen - Internal utilities to generate magickeys. |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = '0.1'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYNOPSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use Archive::Rgssad::Keygen qw(keygen); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $seed = 0xDEADCAFE; |
23
|
|
|
|
|
|
|
my $key = keygen($seed); # get next key |
24
|
|
|
|
|
|
|
my @keys = keygen($seed, 10); # get next 10 keys |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DESCRIPTION |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item keygen $key |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item keygen $key, $num |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Uses KEY as seed, generates NUM keys, and stores the new seed back to KEY. |
36
|
|
|
|
|
|
|
If NUM is omitted, it generates 1 key, which is exactly KEY. |
37
|
|
|
|
|
|
|
In scalar context, returns the last keys generated. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub keygen (\$;$) { |
42
|
4
|
|
|
4
|
|
3607
|
use integer; |
|
4
|
|
|
|
|
41
|
|
|
4
|
|
|
|
|
18
|
|
43
|
33
|
|
|
33
|
1
|
5535
|
my $key = shift; |
44
|
33
|
|
100
|
|
|
88
|
my $num = shift || 1; |
45
|
33
|
|
|
|
|
43
|
my @ret = (); |
46
|
33
|
|
|
|
|
60
|
for (1 .. $num) { |
47
|
217
|
|
|
|
|
189
|
push @ret, $$key; |
48
|
217
|
|
|
|
|
269
|
$$key = ($$key * 7 + 3) & 0xFFFFFFFF; |
49
|
|
|
|
|
|
|
} |
50
|
33
|
100
|
|
|
|
187
|
return wantarray ? @ret : $ret[-1]; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=back |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 AUTHOR |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Zejun Wu, C<< >> |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 SUPPORT |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
perldoc Archive::Rgssad::Keygen |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
You can also look for information at: |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * GitHub |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
L |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Copyright 2012 Zejun Wu. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
83
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
84
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
See L for more information. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=cut |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
1; # End of Archive::Rgssad::Keygen |