in reply to Password (pseudo)casual
It looks like you're trying to get a 20-character random password generated using the characters from 'a' through 'z'. Here's a solution that uses Bytes::Random::Secure:
perl -MBytes::Random::Secure=random_string_from -E 'say random_string_ +from( join("", "a" .. "z" ), 20 );'
Bytes::Random::Secure uses Math::Random::ISAAC as the Random Number Generator, and relies on Crypt::Random::Source to generate a strong seed for the ISAAC generator. The random_string_from function takes care to be free from modulo bias regardless of source string length.
The current release of Bytes::Random::Secure on CPAN has a sort of hefty dependency chain due to its use of Crypt::Random::Source. The next release (due out in a few days) will replace Crypt::Random::Source with Dana Jacobsen's new Crypt::Random::Seed, which is designed to some degree with Bytes::Random::Secure in mind. It has core-only dependencies, provides better fall-backs and portability than Crypt::Random::Source. The next version of Bytes::Random::Secure (watch for v0.20) will also provide an OO interface alongside the functions interface for times when the user requires more control over how ISAAC is seeded.
Dave
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Password (pseudo)casual
by cisco88 (Beadle) on Jan 23, 2013 at 21:19 UTC |