summaryrefslogtreecommitdiffstats
path: root/tests/random.pm
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
committermanuel <manuel@mausz.at>2012-03-27 11:51:08 +0200
commit4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b (patch)
tree868c52e06f207b5ec8a3cc141f4b8b2bdfcc165c /tests/random.pm
parenteae0bd57f0a26314a94785061888d193d186944a (diff)
downloadprogos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.gz
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.tar.bz2
progos-4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b.zip
reorganize file structure to match the upstream requirements
Diffstat (limited to 'tests/random.pm')
-rw-r--r--tests/random.pm27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/random.pm b/tests/random.pm
new file mode 100644
index 0000000..be008ff
--- /dev/null
+++ b/tests/random.pm
@@ -0,0 +1,27 @@
1use strict;
2use warnings;
3
4use tests::arc4;
5
6my (@arc4);
7
8sub 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
16sub random_bytes {
17 random_init ();
18 my ($n) = @_;
19 return arc4_crypt (\@arc4, "\0" x $n);
20}
21
22sub random_ulong {
23 random_init ();
24 return unpack ("V", random_bytes (4));
25}
26
271;