Crypt::Diceware - Random passphrase generator loosely based on the Diceware algorithm


version 0.005


  use Crypt::Diceware;
  my @phrase = words(4); # qw/starker call recur outlaw/

  # with alternate word lists
  use Crypt::Diceware words => { wordlist => 'Original' };
  use Crypt::Diceware words => { wordlist => 'Beale' };


This module generates a random passphrase of words based loosely on the Diceware algorithm by Arnold G. Reinhold.

A Diceware passphrase consists of randomly selected words chosen from a list of over seven thousand words. A passphrase of four or five words is likely to be stronger than typical human-generated passwords, which tend to be too-short and over-sample common letters ("e") and numbers ("1").

Words are randomly selected using Data::Entropy in AES counter mode, seeded with Crypt::URandom, which is reasonably cryptographically strong.


By default, this module exports a single subroutine, words, which uses the Crypt::Diceware::Wordlist::Common word list.

An alternate wordlist may be specified:

  use Crypt::Diceware words => { wordlist => 'Original' };

This loads the wordlist provided by Crypt::Diceware::Wordlist::Original. If the name of the wordlist contains :: the name of the wordlist is not prefixed by Crypt::Diceware::Wordlist.

It is also possible to load a wordlist from a file via:

  use Crypt::Diceware words => { file => 'diceware-german.txt' };

The supplied file should contain one word per line.

You can also replace the entropy source with another Data::Entropy::Source object:

  use Crypt::Diceware words => { entropy => $entropy_source };

Exporting is done via Sub::Exporter so any of its features may be used:

  use Crypt::Diceware words => { -as => 'passphrase' };
  my @phrase = passphrase(4);


  my @phrase = words(4);

Takes a positive numeric argument and returns a passphrase of that many randomly-selected words. In a list context it will return a list of words, as above. In a scalar context it will return a string with the words separated with a single space character:

  my $phrase = words(4);

Returns the empty list / string if the argument is missing or not a positive number.


Diceware and Crypt::Diceware related:

Other CPAN passphrase generators:

About password strength in general:


Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

  git clone


David Golden <>


  • Mario Domgoergen <>

  • Neil Bowers <>


This software is Copyright (c) 2013 by David Golden.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004