mirror of
https://github.com/dmuth/diceware.git
synced 2024-11-21 16:36:28 -05:00
Added EFF wordlist, and updated PHP script and shell script to generate it.
Also updated the generated Javascript to show the source. #6
This commit is contained in:
parent
05065bbea4
commit
898377962a
7 changed files with 15652 additions and 11 deletions
|
@ -19,8 +19,9 @@ if (php_sapi_name() != "cli") {
|
||||||
*/
|
*/
|
||||||
function printSyntax($progname) {
|
function printSyntax($progname) {
|
||||||
|
|
||||||
print "Syntax: $progname [ --dice n ]\n\n"
|
print "Syntax: $progname [ --dice n | --eff ]\n\n"
|
||||||
. "\t--dice Number of dice to generate a wordlist for. Must be between 5 and 7 inclusive. Defaults to 5.\n"
|
. "\t--dice Number of dice to generate a wordlist for. Must be between 5 and 7 inclusive. Defaults to 5.\n"
|
||||||
|
. "\t--eff Generate wordlist against the EFF's list, found at https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases"
|
||||||
. "\n"
|
. "\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -57,12 +58,22 @@ function parseArgs($argv) {
|
||||||
$retval["dice"] = $value_next;
|
$retval["dice"] = $value_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($value == "--eff") {
|
||||||
|
$retval["eff"] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($retval["dice"])) {
|
||||||
if ($retval["dice"] < 5 || $retval["dice"] > 7) {
|
if ($retval["dice"] < 5 || $retval["dice"] > 7) {
|
||||||
printSyntax($progname);
|
printSyntax($progname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else if (!isset($retval["eff"])) {
|
||||||
|
printSyntax($progname);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return($retval);
|
return($retval);
|
||||||
|
|
||||||
} // End of parseArgs()
|
} // End of parseArgs()
|
||||||
|
@ -139,20 +150,71 @@ function readWordListPeterNorvig($filename, $dice) {
|
||||||
} // End of readWordListPeterNorvig()
|
} // End of readWordListPeterNorvig()
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Read in the EFF's wordlist and return an array with all the words.
|
||||||
|
*
|
||||||
|
* @param string $filename The filename
|
||||||
|
*
|
||||||
|
* @return array An array of words
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function readWordListEff($filename) {
|
||||||
|
|
||||||
|
$retval = array();
|
||||||
|
|
||||||
|
$fp = @fopen($filename, "r");
|
||||||
|
if (!$fp) {
|
||||||
|
throw new Exception("Could not open '$filename' for reading");
|
||||||
|
}
|
||||||
|
|
||||||
|
while ($line = fgets($fp)) {
|
||||||
|
|
||||||
|
$line = rtrim($line);
|
||||||
|
list($roll, $word) = explode("\t", $line);
|
||||||
|
|
||||||
|
$retval[] = $word;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Put the words in alphabetical order for my own sanity.
|
||||||
|
//
|
||||||
|
sort($retval);
|
||||||
|
|
||||||
|
fclose($fp);
|
||||||
|
|
||||||
|
return($retval);
|
||||||
|
|
||||||
|
} // End of readWordListEff()
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create our Javascript, but as an array
|
* Create our Javascript, but as an array
|
||||||
*
|
*
|
||||||
* @param array $words Our array of words
|
* @param array $words Our array of words
|
||||||
*
|
*
|
||||||
|
* @param array $param Our array of params
|
||||||
|
*
|
||||||
* @return string Javascript which defines an array of those words
|
* @return string Javascript which defines an array of those words
|
||||||
*/
|
*/
|
||||||
function getJsArray($words) {
|
function getJsArray($words, $params) {
|
||||||
|
|
||||||
|
$url = "(unknown)";
|
||||||
|
|
||||||
|
if (isset($params["dice"])) {
|
||||||
|
$url = "http://norvig.com/ngrams/";
|
||||||
|
|
||||||
|
} else if (isset($params["eff"])) {
|
||||||
|
$url = "https://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$retval = ""
|
$retval = ""
|
||||||
. "//\n"
|
. "//\n"
|
||||||
. "// Our wordlist.\n"
|
. "// Our wordlist.\n"
|
||||||
. "//\n"
|
. "//\n"
|
||||||
. "// Originally obtained from http://norvig.com/ngrams/\n"
|
. "// Originally obtained from: $url\n"
|
||||||
. "//\n"
|
. "//\n"
|
||||||
. "var wordlist = [\n"
|
. "var wordlist = [\n"
|
||||||
;
|
;
|
||||||
|
@ -186,18 +248,31 @@ function getJsArray($words) {
|
||||||
function main($argv) {
|
function main($argv) {
|
||||||
|
|
||||||
$params = parseArgs($argv);
|
$params = parseArgs($argv);
|
||||||
|
//print_r($params); // Debugging
|
||||||
|
|
||||||
//
|
//
|
||||||
// Read our file
|
// Read our file
|
||||||
//
|
//
|
||||||
|
if (isset($params["dice"])) {
|
||||||
$filename = "count_1w.txt";
|
$filename = "count_1w.txt";
|
||||||
$words = readWordListPeterNorvig($filename, $params["dice"]);
|
$words = readWordListPeterNorvig($filename, $params["dice"]);
|
||||||
//print_r($words); // Debugging
|
//print_r($words); // Debugging
|
||||||
|
|
||||||
|
} else if (isset($params["eff"])) {
|
||||||
|
//
|
||||||
|
// Handle wordllist from https://www.eff.org/files/2016/07/18/eff_large_wordlist.txt
|
||||||
|
//
|
||||||
|
$filename = "eff_large_wordlist.txt";
|
||||||
|
$words = readWordListEff($filename);
|
||||||
|
//print_r($words); // Debugging
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Get our Javascript
|
// Get our Javascript
|
||||||
//
|
//
|
||||||
$js = getJsArray($words);
|
$js = getJsArray($words, $params);
|
||||||
|
|
||||||
print $js;
|
print $js;
|
||||||
|
|
||||||
|
|
7776
wordlist/eff_large_wordlist.txt
Normal file
7776
wordlist/eff_large_wordlist.txt
Normal file
File diff suppressed because it is too large
Load diff
|
@ -27,6 +27,12 @@ echo "# Creating wordlist '$JS'..."
|
||||||
echo "# "
|
echo "# "
|
||||||
./create-wordlist.php --dice 7 > ${JS}
|
./create-wordlist.php --dice 7 > ${JS}
|
||||||
|
|
||||||
|
JS="wordlist-5-dice-eff.js"
|
||||||
|
echo "# "
|
||||||
|
echo "# Creating EFF 5-dice Wordlist..."
|
||||||
|
echo "# "
|
||||||
|
./create-wordlist.php --eff > ${JS}
|
||||||
|
|
||||||
echo "# "
|
echo "# "
|
||||||
echo "# Done!"
|
echo "# Done!"
|
||||||
echo "# "
|
echo "# "
|
||||||
|
|
7784
wordlist/wordlist-5-dice-eff.js
Normal file
7784
wordlist/wordlist-5-dice-eff.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Our wordlist.
|
// Our wordlist.
|
||||||
//
|
//
|
||||||
// Originally obtained from http://norvig.com/ngrams/
|
// Originally obtained from: http://norvig.com/ngrams/
|
||||||
//
|
//
|
||||||
var wordlist = [
|
var wordlist = [
|
||||||
"aaliyah",
|
"aaliyah",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Our wordlist.
|
// Our wordlist.
|
||||||
//
|
//
|
||||||
// Originally obtained from http://norvig.com/ngrams/
|
// Originally obtained from: http://norvig.com/ngrams/
|
||||||
//
|
//
|
||||||
var wordlist = [
|
var wordlist = [
|
||||||
"aaaah",
|
"aaaah",
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
//
|
//
|
||||||
// Our wordlist.
|
// Our wordlist.
|
||||||
//
|
//
|
||||||
// Originally obtained from http://norvig.com/ngrams/
|
// Originally obtained from: http://norvig.com/ngrams/
|
||||||
//
|
//
|
||||||
var wordlist = [
|
var wordlist = [
|
||||||
"aaaa",
|
"aaaa",
|
||||||
|
|
Loading…
Reference in a new issue