table of contents
| Crypt::SysRandom(3) | User Contributed Perl Documentation | Crypt::SysRandom(3) |
NAME¶
Crypt::SysRandom - Perl interface to system randomness
VERSION¶
version 0.008
SYNOPSIS¶
use Crypt::SysRandom 'random_bytes'; my $random = random_bytes(16);
DESCRIPTION¶
This module uses whatever interface is available to procure cryptographically random data from the system. All functions are optionally exported.
FUNCTIONS¶
random_bytes($count)¶
This will fetch a string of $count random bytes containing cryptographically secure random data.
random_hex($count)¶
This will fetch a string of $count random bytes containing cryptographically secure random data and hex encode it (so the result will be twice as many bytes).
random_base64($count)¶
This will fetch a string of $count random bytes containing cryptographically secure random data and base64 encode it (so the result will be about 33% larger).
random_base64url($count)¶
This will fetch a string of $count random bytes containing cryptographically secure random data and base64url encode it (so the result will be about 33% larger).
random_uuid()¶
This will generate a cryptographically random UUIDv4.
Backends¶
The current backends are tried in order:
- Crypt::SysRandom::XS
- "RtlGenRandom" using Win32::API
- "/dev/urandom"
AUTHOR¶
Leon Timmermans <fawaka@gmail.com>
COPYRIGHT AND LICENSE¶
This software is copyright (c) 2025 by Leon Timmermans.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
| 2026-11-06 | perl v5.44.0 |