Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Password (pseudo)casual

by davido (Archbishop)
on Jan 23, 2013 at 18:04 UTC ( #1014972=note: print w/replies, xml ) Need Help??

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.


Replies are listed 'Best First'.
Re^2: Password (pseudo)casual
by cisco88 (Beadle) on Jan 23, 2013 at 21:19 UTC
    Thanks :)
    -- Luca Francesca
    Vodafone Italy & Ntt Data

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1014972]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2018-02-25 19:55 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (314 votes). Check out past polls.