NAME
Crypt::URandom::MonkeyPatch - override core rand function to use system random sources
SYNOPSIS
use Crypt::URandom::MonkeyPatch;
DESCRIPTION
This module globally overrides the builtin Perl function rand with one based on the operating system's cryptographic
random number source, e.g. /dev/urandom.
The purpose of this module is monkey patch legacy code that uses rand for security purposes.
You can verify that it is working by running code with the CRYPT_URANDOM_MONKEYPATCH_DEBUG environment variable set,
e.g.
local $ENV{CRYPT_URANDOM_MONKEYPATCH_DEBUG} = 1;
my $salt = random_string("........");
Every time the rand function is called, it will output a line such as
Crypt::URandom::MonkeyPatch::urandom used from Some::Package line 123
RECENT CHANGES
Changes for version v0.1.4 (2026-05-06)
- Security
- Set minimum version of Crypt::URandom.
- Documentation
- Update copyright year.
- Update author email address.
- Fix SOURCE link in the documentation.
- Toolchain
- Stop signing distributions due to Module::Signature deprecation.
- Add doap.xml to the distribution.
See the Changes file for more details.
REQUIREMENTS
This module lists the following modules as runtime dependencies:
- Crypt::URandom version 0.55 or later
- constant
- perl version v5.8.0 or later
- strict
- version version 0.77 or later
- warnings
See the cpanfile file for the full list of prerequisites.
INSTALLATION
The latest version of this module (along with any dependencies) can be installed from CPAN with the cpan tool that is included with Perl:
cpan Crypt::URandom::MonkeyPatch
You can also extract the distribution archive and install this module (along with any dependencies):
cpan .
You can also install this module manually using the following commands:
perl Makefile.PL
make
make test
make install
If you are working with the source repository, then it may not have a Makefile.PL file. But you can use the Dist::Zilla tool in anger to build and install this module:
dzil build
dzil test
dzil install --install-command="cpan ."
For more information, see How to install CPAN modules.
SUPPORT
Only the latest version of this module will be supported.
Only Perl versions released in the past ten (10) years are supported, even though this module may run on earlier versions.
Please report any bugs or feature requests on the bugtracker website https://github.com/robrwo/perl-Crypt-URandom-MonkeyPatch/issues
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Reporting Security Vulnerabilities
Security issues should not be reported on the bugtracker website. Please see SECURITY.md for instructions how to
report security vulnerabilities.
SOURCE
The development version is on github at https://github.com/robrwo/perl-Crypt-URandom-MonkeyPatch and may be cloned from https://github.com/robrwo/perl-Crypt-URandom-MonkeyPatch.git
AUTHOR
Robert Rothenberg perl@rhizomnic.com
COPYRIGHT AND LICENSE
This software is Copyright (c) 2025-2026 by Robert Rothenberg perl@rhizomnic.com.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)