接口说明:
检测密码强度, 1~3 较弱 4~6 一般 6~10 强
接口源代码PHP:
<?php
/**
* 检测密码强度接口 PHP接口源代码
*
* 最后修改:2024-10-12 16:01:01
*
* @author dogstar www.yesapi.cn
*
* 来源:https://open.yesapi.cn/apicode/8857.html
*/
function ($params, $di) {
$password = $params['password'];
if (empty($password)) return '用户名和密码不允许为空!';
$score = 0;
if (preg_match("/[0-9]+/", $password)) $score++;
if (preg_match("/[0-9]{3,}/", $password)) $score++;
if (preg_match("/[a-z]+/", $password)) $score++;
if (preg_match("/[a-z]{3,}/", $password)) $score++;
if (preg_match("/[A-Z]+/", $password)) $score++;
if (preg_match("/[A-Z]{3,}/", $password)) $score++;
if (preg_match("/[_\-+=*!@#$%^&()]+/", $password)) $score += 2;
if (preg_match("/[_\-+=*!@#$%^&()]{3,}/", $password)) $score++;
if (strlen($password) >= 10) $score++;
return ['score' => $score];
}
在线运行
