mcrumley / php-complexify
Dan Palmer的jquery.complexify.js的PHP版本
v0.4.1
2018-02-19 23:05 UTC
This package is not auto-updated.
Last update: 2024-09-14 16:37:48 UTC
README
PHP版本的jquery.complexify.js
安装
composer require mcrumley/php-complexify
用法
$check = new \Complexify\Complexify(); $result = $check->evaluateSecurity('correct horse battery staple'); echo round($result->complexity, 1) . '% '; if ($result->valid) { echo 'VALID'; } else { echo 'NOT VALID: '.implode(', ', $result->errors); }
配置
您可以通过向构造函数传递一个数组来覆盖默认配置。
$check = new \Complexify\Complexify(array( 'minimumChars' => 8, // the minimum acceptable password length 'strengthScaleFactor' => 1, // scale the required password strength (higher numbers require a more complex password) 'bannedPasswords' => array(), // override the default banned password list 'banMode' => 'strict', // strict == don't allow substrings of banned passwords, loose == only ban exact matches 'encoding' => 'UTF-8', // password string encoding ));
返回值
evaluateSecurity
方法返回一个包含以下属性的对象
- valid - 如果密码通过所有检查,则为
TRUE
- complexity - 计算的复杂度作为最大值的百分比(25个字符,至少包含每个集合中的一个)
- errors - 0个或多个字符串,解释未通过的检查
- banned
- tooshort
- toosimple
许可证
此代码根据WTFPL v2许可证分发。
版本历史
0.4 - 将banmode选项更改为banMode
0.3.1 - 添加了Composer支持
0.3 - 首次发布(匹配JS版本号)