projects
/
pintos-anon
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
Fix inconstiency in recent_cpu update description.
[pintos-anon]
/
src
/
tests
/
random.pm
1
use strict;
2
use warnings;
3
4
use tests::arc4;
5
6
my (@arc4);
7
8
sub random_init {
9
if (@arc4 == 0) {
10
my ($seed) = @_;
11
$seed = 0 if !defined $seed;
12
@arc4 = arc4_init (pack ("V", $seed));
13
}
14
}
15
16
sub random_bytes {
17
random_init ();
18
my ($n) = @_;
19
return arc4_crypt (\@arc4, "\0" x $n);
20
}
21
22
sub random_ulong {
23
random_init ();
24
return unpack ("V", random_bytes (4));
25
}
26
27
1;