Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 6739bfc44add802c338612a310787e3dfcb2af28 @jatenate committed May 26, 2012
Showing with 15,598 additions and 0 deletions.
  1. +9 −0 README.md
  2. +18 −0 lib/diceware.js
  3. +7,776 −0 lib/diceware.wordlist.txt
  4. +7,778 −0 lib/wordlist.js
  5. +17 −0 package.json
9 README.md
@@ -0,0 +1,9 @@
+# A simple diceware module
+
+`diceware` generates passphrases using the [diceware method](http://world.std.com/~reinhold/diceware.html).
+
+It's worth noting that [it's not recommended](http://world.std.com/~reinhold/dicewarefaq.html#electronic) to use a computer to generate a Diceware phrase. If you want to generate passphrases in node.js, check out [https://github.com/shimaore/password](https://github.com/shimaore/password) instead.
+
+ diceware = require('diceware');
+ console.log(diceware()); // by default generates a 5 word phrase
+ console.log(diceware(10)); // but number of words can optionally be specified
18 lib/diceware.js
@@ -0,0 +1,18 @@
+var wordlist = require('./wordlist');
+
+var DEFAULT_NUMWORDS = 5;
+var WORDLIST_SIZE = 7776; // 6^5
+
+module.exports = function(numwords) {
+ numwords = numwords || DEFAULT_NUMWORDS;
+
+ var phrase = "";
+
+ for (var i = 0 ; i < numwords ; i++) {
+ var rand = Math.floor(Math.random() * WORDLIST_SIZE);
+ phrase += wordlist[rand] + " ";
+ }
+
+ // remove the trailing space
+ return phrase.substring(0, phrase.length - 1);
+}
7,776 lib/diceware.wordlist.txt
7,776 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
7,778 lib/wordlist.js
7,778 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
17 package.json
@@ -0,0 +1,17 @@
+{
+ "name": "diceware",
+ "version": "0.0.1",
+ "description": "Simple diceware utility (http://world.std.com/~reinhold/diceware.html)",
+ "keywords": [
+ "diceware",
+ "generate",
+ "passphrase"
+ ],
+ "homepage": "http://www.github.com/jatenate/diceware",
+ "main": "lib/diceware.js",
+ "author": "Justin Hurley (@jmh)",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/jatenate/diceware.git"
+ }
+}

0 comments on commit 6739bfc

Please sign in to comment.