NAME
Crypt::XkcdPassword - see http://xkcd.com/936/
SYNOPSIS
use 5.010;
use Crypt::XkcdPassword;
say Crypt::XkcdPassword->make_password;
DESCRIPTION
Yet another password generator module inspired by http://xkcd.com/936/.
Constructor
new(%attr)
Creates a new generator. A single generator can be used to generate as many passwords as you like.
Attributes
This module doesn't use Moose, but uses its "mini-me", Mo. Like Moose, Mo provides the concept of attributes, which have a getter/setter method.
words
A string which will be appended to
Crypt::XkcdPassword::Words::
to form a class name which will be used as a source for words. The default is "EN", which means the class used as a source for words isCrypt::XkcdPassword::Words::EN
.Crypt::XkcdPassword::Words::EN
is a list of 10,000 common English words.Also supplied is "IT", a list of 20,000 common Italian words.
rng
A coderef for generating a random number. The coderef is called and passed a single numeric argument. The coderef is expected to generate a random, positive integer, smaller than the argument. The default is:
sub { int(rand($_[0])) }
Perl's default random number generator is often though insufficient for practical cryptography, so you may wish to use another random number generator.
Methods
make_password($size)
Returns the password as a string.
$size is the length of the password in words. It defaults to 4. For the English dictionary that provides over 47 bits of entropy; for the Italian dictionary (which has twice as many words), about 56 bits of entropy.
For reference, 47 bits of entropy is roughly equivalent to an eight digit random case-sensitive alphanumeric password (i.e. 62^8).
This can be called as an object method, or (if you have no desire to change the defaults for the
rng
andwords
attributes) as a class method. That is, the first line of the example below is a shortcut for the second line:say Crypt::XkcdPassword->make_password($size); say Crypt::XkcdPassword->new->make_password($size);
Note that the passphrases returned may not be ASCII-safe, and may sometimes be inappropriate for uttering in polite company.
chars
No-op, provided for compatibility with Data::SimplePassword.
provider
No-op, provided for compatibility with Data::SimplePassword.
BUGS
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Crypt-XkcdPassword.
SEE ALSO
Data::SimplePassword - I borrowed this module's interface, so it should mostly be possible to s/Data::SimplePassword/Crypt::XkcdPassword/.
Crypt::PW44 - similar to this one, but with a smaller list of words.
AUTHOR
Toby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCE
This software is copyright (c) 2012 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.