1Crypt::URandom(3) User Contributed Perl Documentation Crypt::URandom(3)
2
3
4
6 Crypt::URandom - Provide non blocking randomness
7
9 This document describes Crypt::URandom version 0.39
10
12 use Crypt::URandom();
13
14 my $random_string_50_bytes_long = Crypt::URandom::urandom(50);
15
16 OR
17
18 use Crypt::URandom qw( urandom );
19
20 my $random_string_50_bytes_long = urandom(50);
21
23 This Module is intended to provide an interface to the strongest
24 available source of non-blocking randomness on the current platform.
25 Platforms currently supported are anything supporting /dev/urandom and
26 versions of Windows greater than or equal to Windows 2000.
27
29 "urandom"
30 This function accepts an integer and returns a string of the same
31 size filled with random data. The first call will initialize the
32 native cryptographic libraries (if necessary) and load all the
33 required Perl libraries. This call is a buffered read on non Win32
34 platforms.
35
36 "urandom_ub"
37 This function accepts an integer and returns a string of the same
38 size filled with random data. The first call will initialize the
39 native cryptographic libraries (if necessary) and load all the
40 required Perl libraries. This call is a unbuffered sysread on non
41 Win32 platforms.
42
44 "No secure alternative for random number generation for Win32 versions
45 older than W2K"
46 The module cannot run on versions of Windows earlier than Windows
47 2000 as there is no cryptographic functions provided by the
48 operating system.
49
50 "Could not import CryptAcquireContext"
51 The module was unable to load the CryptAcquireContextA function
52 from the advapi32 dynamic library. The advapi32 library cannot
53 probably be loaded.
54
55 "CryptAcquireContext failed"
56 The module was unable to call the CryptAcquireContextA function
57 from the advapi32 dynamic library.
58
59 "Could not import CryptGenRandom"
60 The module was unable to load the CryptGenRandom function from the
61 advapi32 dynamic library.
62
63 "Could not import SystemFunction036"
64 The module was unable to load the SystemFunction036 function from
65 the advapi32 dynamic library.
66
67 "The length argument must be supplied and must be an integer"
68 The get method must be called with an integer argument to describe
69 how many random bytes are required.
70
71 "CryptGenRandom failed"
72 The Windows 2000 CryptGenRandom method call failed to generate the
73 required amount of randomness
74
75 "RtlGenRand failed"
76 The post Windows 2000 RtlGenRand method call failed to generate the
77 required amount of randomness
78
79 "Only read n bytes from path"
80 The /dev/urandom device did not return the desired amount of random
81 bytes
82
83 "Failed to read from path"
84 The /dev/urandom device returned an error when being read from
85
86 "Failed to open path"
87 The /dev/urandom device returned an error when being opened
88
90 Crypt::URandom requires no configuration files or environment
91 variables.
92
94 If the platform is Win32, the Win32::API module will be required.
95 Otherwise no other modules other than those provided by perl will
96 be required
97
99 None reported.
100
102 No bugs have been reported.
103
104 Please report any bugs or feature requests to
105 "bug-crypt-urandom@rt.cpan.org", or through the web interface at
106 <http://rt.cpan.org>.
107
109 David Dick "<ddick@cpan.org>"
110
112 The Win32::API code for interacting with Microsoft's CryptoAPI was
113 stolen with extreme gratitude from Crypt::Random::Source::Strong::Win32
114 by Max Kanat-Alexander
115
117 Copyright (c) 2023, David Dick "<ddick@cpan.org>". All rights reserved.
118
119 This module is free software; you can redistribute it and/or modify it
120 under the same terms as Perl itself.
121
123 BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
124 FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT
125 WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER
126 PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND,
127 EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
128 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
129 ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
130 YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
131 NECESSARY SERVICING, REPAIR, OR CORRECTION.
132
133 IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
134 WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
135 REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
136 TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
137 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
138 SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
139 RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
140 FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
141 SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
142 DAMAGES.
143
144
145
146perl v5.38.0 2023-07-20 Crypt::URandom(3)