elcodedocle/chbspassgen

安全且易于记忆的高熵密码生成器。基于词典,但抗暴力破解。

0.1.0 2024-09-02 18:10 UTC

This package is not auto-updated.

Last update: 2024-09-30 18:44:32 UTC


README

生成易于记忆且熵值高的强大密码

版权 (C) 2014 Gael Abadin
许可证: MIT Expat

chbspassgen password generator test site snapshot with default settings

动机

我想创建一个能够以安全方式从词典中随机选择单词的类,以便将它们建议为安全的密码(正确,马。那是电池夹子)。

如何使用

基本用法

require_once 'cryptosecureprng/CryptoSecurePRNG.php';
require_once 'dictionary/DictionaryInterface.php';
require_once 'dictionary/Dictionary.php';
require_once 'PasswordGeneratorAbstract.php';
require_once 'PasswordGenerator.php';

$passwordGenerator = new synapp\info\tools\passwordgenerator\PasswordGenerator();  // Expects a dictionary generated from a source on a file named 'top10000.txt'

$password = $passwordGenerator->generatePassword(); // Generates a password with default settings

$entropy = $passwordGenerator->getEntropy(); // entropy of the last generated password (won't change unless you change settings)

就是这样。很简单,对吧?不过还有很多参数可以调整。

// Here is a quick debrief on the class constructor parameters (See the phpdoc blocks for more info):

$passwordGenerator = new synapp\info\tools\passwordgenerator\PasswordGenerator(
  // the dictionary 
  // (null defaults to new Dictionary($this->defaultDictionaryFilename,$minReadWordsWordSize))
  // with $this->defaultDictionaryFilename set to 'top10000.txt'
  $dictionary = null, 
  // set the level of entropy used when none is explicitly specified on the generatePassword() call
  // (null defaults to $this->defaultLevel, set to 2)
  $level = 2, 
  // a string of unique chars from where to randomly choose the password separator 
  // (null defaults to $this->defaultSeparator, set to ' ')
  $separators = ' ', 
  // an ascending ordered array of ints containing the minimum entropies for each level
  // (null defaults to $this->defaultMinEntropies, set to array(64,80,112,128))
  $minEntropies = array(64,80,112,128), 
  // boolean, whether to use selected random variations on the password words to increase entropy 
  // defaults to true
  $useVariations = false, 
  // (array of booleans which activate random variations on the words, increasing entropy. 
  // Valid keys: 'allcaps', 'capitalize', 'punctuate', 'addslashes'). Use null for defaults.
  $variations = null, 
  // Minimum length of the words used to create the password
  // (null defaults to $this->defaultMinWordSize, set to 4)
  $minWordSize = 4, 
  // Minimum length of the words read from the dictionary source
  // (null defaults to $this->defaultMinReadWordsWordSize, set to 4)
  $minReadWordsWordSize = 4, //(minimum length of the words read from the Dictionary source)
  // the pseudoaleatory random generator (new CryptoSecurePRNG() by default)
  $prng = new synapp\info\tools\passwordgenerator\cryptosecureprng\CryptoSecurePRNG() 
);

// generatePassword method takes almost the same parameters as the contructor:

$password = $passwordGenerator->generatePassword(
  $dictionary = null,     // use null to skip parameters (set to the current setting)
  $minEntropy = null,     // and here too, and anywhere else when you want to
  $level = 1,             // specify further parameters like this one
  $separators = '_ -',    // and this one
  $useVariations = true,  // and this one
  $variations = array(    // and this one too 
    'allcaps'=>true,      // (BTW, this system also works in the constructor, where you can
    'capitalize'=>true    // specify some params and leave others to their defaults using null)
  ) 
);


// getEntropy can return a pretty accurate estimate of the entropy of the last generated 
// password, but can also be given a password and a set of parameters to extract its entropy

$entropy = $passwordGenerator->getEntropy(
 $password, 
 $dictionary = null, 
 $variationsCount = null, 
 $lastOrSeparator = true, 
 $separatorsCount = null
);

查看代码(或使用phpdocumentor生成文档)以获取有关调整和可用参数的更多信息。

Web应用

还有一个可用的演示Web应用(passgenController.phppassgenClientController.jspassword_generator.html),您可以将所有文件上传到Web服务器的公共文件夹,并通过将浏览器指向password_generator.html来加载它。

这里是演示:https://synapp.info/password-generator

致谢

Caffeine。

Peter Norvig,因为他是一位如此棒的教授(查看他的斯坦福大学人工智能课程)并发布了包含三百万个最常用英语单词的汇编,该项目中默认词典源所使用的单词列表就是从中派生出来的(也要感谢Josh Kaufman的建议)。

Randall Munroe。他很幽默,聪明,有启发性。谢谢,Munroe先生。

就到这里了,朋友们。如果您喜欢这个项目,请随意请我喝啤酒 ;-)

bitcoin: 1A7rSMddjwPbxFW71ZD724YaQLa8HCAJTT

dogecoin: DAQBLYtCjBnZ8eGdcaR7kE517Ew5tptUeW

paypal: http://goo.gl/RQVD5u

祝您玩得开心。-