Math::...:ChaCha(3pm)
π Math::...:ChaCha(3pm) π
okay so bestie, you found the User Contributed Perl Documentation for this one β it's the Math::Prime::Util::ChaCha page, aka a Pure Perl ChaCha20 CSPRNG β¨ like, a whole cryptographically-secure random number generator, written in Perl, no cap π«Ά
β¨ VERSION β¨
Version 0.74 πΈ (yes she has a version number, she's a real one)
π SYNOPSIS π
ngl, the original page leaves this section completely blank π« no synopsis, no example, nothing. Just vibes. So we're honoring that β no invented code here, bestie, i'm not about to make stuff up π
π¦ DESCRIPTION π¦
It's a pure Perl implementation of ChaCha20 that comes with a CSPRNG interface. That's it. That's the whole description. Short, iconic, to the point π
π FUNCTIONS π
π csrand
She takes a binary string as her input and uses it to seed the internal CSPRNG. Give her your bytes, she gets the whole thing going π
π srand
This one is a method for sieving the CSPRNG with a small value.
β οΈ heads up bestie: this is NOT secure. like, do not use it for anything that matters, okay? π it's for simulations and for emulating the system srand β that's the whole point of her.
How she behaves:
- No argument? She chooses a random number, seeds with it, and hands the number back to you π
- One integer argument? She seeds with it and returns that number back to you π
π irand
Returns a random 32-bit integer π₯
π irand64
Returns a random 64-bit integer π₯π₯ (she's the tall one)
π random_bytes
Takes an unsigned number n as input and returns that many random bytes, all bundled up as a single binary string. So like random_bytes(16) β 16 bytes of chaos in one string, slay π
πΈ AUTHORS πΈ
Dana Jacobsen <dana@acm.org> β the icon, the moment, the whole reason this page exists π
π ACKNOWLEDGEMENTS π
Daniel J. Bernstein wrote the ChaCha family of stream ciphers back in 2008, as an update to the popular Salsa20 cipher from 2005. the way he just kept iterating, king behavior fr fr π
RFC7539: "ChaCha20 and Poly1305 for IETF Protocols" was used to create both the C and the Perl implementations. and the test vectors from that document are used here as well π§ͺβ¨ (test vectors, the unsung heroes)
For the final optimizations, ideas were borrowed from Christopher Madsen's Crypt::Salsa20 β specifically for how to best work around some of Perl's aggressive dynamic typing π (perl, please). and fun fact: our core is still about 20% slower than Salsa20. not her being just a little bit behind, but she's still out here doing the thing πͺ
π COPYRIGHT π
Copyright 2017 by Dana Jacobsen <dana@acm.org> π«Ά
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. periodt π
and that's the whole page bestie!! this one's running on perl v5.42.3, dated 2026-08-20 β so if you're reading this from the future, hi, hope the randomness is random πβπ
π¦ where this page comes from
- ubuntu stonking: libmath-prime-util-perl 0.74-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms