Data::E...e::Local(3)

πŸ’– Data::Entropy::RawSource::Local β€” the tea β˜•

okay bestie, so this is Data::Entropy::RawSource::Local(3), a page from the User Contributed Perl Documentation, and it's literally all about pulling raw randomness out of a local device. let's get into it πŸ’…


✨ NAME ✨

Data::Entropy::RawSource::Local β€” read randomness from a local device 🎲


🌸 SYNOPSIS 🌸

use Data::Entropy::RawSource::Local;

my $rawsrc = Data::Entropy::RawSource::Local->new;

$rawsrc->sysread($c, 1);
# and the rest of the I/O handle interface

πŸ¦‹ DESCRIPTION πŸ¦‹

so basically, this class gives you a constructor that opens an I/O handle wired up to a local source of random octets. it may be a strong entropy source depending on your OS β€” but ngl, not every OS even has a facility like this at all. πŸ’€

also, fun fact: there are no actual objects blessed into this class. only the constructor belongs here, and what it hands back are IO::File objects. and if you want to use it as a general entropy source, the move is to wrap that handle using Data::Entropy::Source β€” that one gives you methods to pull entropy out in way more convenient forms than just plain octets. 🫢

on systems with a blocking /dev/random, like Linux, the bits generated can be totally unbiased and uncorrelated. that kind of entropy stream is suitable for all uses, including security applications. iconic. πŸ‘‘ but β€” and this is the catch β€” the rate of entropy generation is limited, so if your app needs a large amount of apparently-random data, you might prefer to fake it cryptographically (peep Data::Entropy::RawSource::CryptCounter). ✨

on systems where /dev/random does not block, the bits generated are necessarily correlated to some extent, but it should be cryptographically difficult to detect that correlation. that kind of entropy source is not suitable for all applications, so watch out. πŸ™ˆ and some other systems just straight up lack /dev/random entirely. not the vibe.


πŸŽ€ CONSTRUCTOR πŸŽ€

  • Data::Entropy::RawSource::Local->new([FILENAME]) β€” opens a file handle referring to the randomness device, or dies on error. the device opened is /dev/random by default, but you can override that by passing a FILENAME argument.

heads up bestie: the default device name may in the future be different on different OSes, if their equivalent devices are in different places. so don't get too attached to the path, okay? πŸ’œ


⭐ METHODS ⭐

there are no actual objects blessed into this class. the constuctor returns IO::File objects. see IO::File for the interface.

and the recommendation: use unbuffered reads (the sysread method) rather than buffered reads (the getc method et al), so you avoid wasting entropy that could be used by another process. fr fr, don't be wasteful with the randomness πŸ“


🌈 SEE ALSO 🌈

  • Data::Entropy::RawSource::CryptCounter
  • Data::Entropy::RawSource::RandomOrg
  • Data::Entropy::RawSource::RandomnumbersInfo
  • Data::Entropy::Source
  • IO::File

πŸ’œ AUTHOR πŸ’œ

Andrew Main (Zefram) <zefram@fysh.org>

Maintained by Robert Rothenberg <perl@rhizomnic.com>


Copyright (C) 2006, 2007, 2009, 2011, 2025-2026 Andrew Main (Zefram) <zefram@fysh.org>


πŸŽ€ LICENSE πŸŽ€

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie πŸ’– this was perl v5.42.3, dated 2026-08-02, served fresh from Data::E...e::Local(3) β€” periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from