line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -sw |
2
|
|
|
|
|
|
|
## |
3
|
|
|
|
|
|
|
## Copyright (c) 1998-2018, Vipul Ved Prakash. All rights reserved. |
4
|
|
|
|
|
|
|
## This code is free software; you can redistribute it and/or modify |
5
|
|
|
|
|
|
|
## it under the same terms as Perl itself. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package Crypt::Random::Provider::rand; |
8
|
1
|
|
|
1
|
|
357
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
9
|
1
|
|
|
1
|
|
5
|
use Math::Pari qw(pari2num); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
4
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
|
|
|
|
|
|
|
13
|
5
|
|
|
5
|
0
|
811
|
my ($class, %params) = @_; |
14
|
5
|
|
50
|
58
|
|
28
|
my $self = { Source => $params{Source} || sub { return rand($_[0]) } }; |
|
58
|
|
|
|
|
92
|
|
15
|
5
|
|
|
|
|
42
|
return bless $self, $class; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub get_data { |
21
|
|
|
|
|
|
|
|
22
|
5
|
|
|
5
|
0
|
11
|
my ($self, %params) = @_; |
23
|
5
|
50
|
|
|
|
10
|
$self = {} unless ref $self; |
24
|
|
|
|
|
|
|
|
25
|
5
|
|
|
|
|
6
|
my $size = $params{Size}; |
26
|
5
|
|
33
|
|
|
13
|
my $skip = $params{Skip} || $$self{Skip}; |
27
|
|
|
|
|
|
|
|
28
|
5
|
50
|
66
|
|
|
12
|
if ($size && ref $size eq "Math::Pari") { |
29
|
0
|
|
|
|
|
0
|
$size = pari2num($size); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
5
|
|
66
|
|
|
15
|
my $bytes = $params{Length} || (int($size / 8) + 1); |
33
|
5
|
|
50
|
0
|
|
8
|
my $source = $$self{Source} || sub { rand($_[0]) }; |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
5
|
|
|
|
|
7
|
my($r, $read, $rt) = ('', 0); |
36
|
5
|
|
|
|
|
8
|
while ($read < $bytes) { |
37
|
58
|
|
|
|
|
48
|
$rt = chr(int(&$source(256))); |
38
|
58
|
50
|
33
|
|
|
80
|
unless ($skip && $skip =~ /\Q$rt\E/) { |
39
|
58
|
|
|
|
|
41
|
$r .= $rt; $read++; |
|
58
|
|
|
|
|
71
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
5
|
|
|
|
|
18
|
$r; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub available { |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
0
|
0
|
|
return 1; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
1; |
56
|
|
|
|
|
|
|
|