❑
ToolsOh!の【密码强度检查】工具的功能
所在位置:ToolsOh/生活工具/密码生成器or密码生成器
主要技术:java、zxcvbn
1、功能简介
使用zxcvbn对密码强度进行估算
2、输入、输出
略
3、程序(算法)说明
maven代码
<dependency>
<groupId>com.nulab-inc</groupId>
<artifactId>zxcvbn</artifactId>
<version>1.5.2</version>
</dependency>
java代码
import com.google.common.base.Joiner;
import com.nulabinc.zxcvbn.Strength;
import com.nulabinc.zxcvbn.Zxcvbn;
import org.passay.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;
import java.util.Locale;
@Component
public class PasswordStrengthValidatorHelper {
private static final Logger logger = LoggerFactory.getLogger(PasswordStrengthValidatorHelper.class);
public Strength passwordStrength(String password) {
Zxcvbn zxcvbn = new Zxcvbn();
Strength strength = zxcvbn.measure(password);
logger.info(strength.getGuesses() + " \n "+
strength.getCalcTime()+" \n "+
strength.getScore()+" \n "+
strength.getPassword()+" \n "+
strength.getFeedback().getSuggestions(Locale.CHINESE)+" \n "+
strength.getCrackTimesDisplay());
return strength;
}
public static void main(String[] args) {
//System.out.println(new PasswordStrengthValidatorHelper().isPasswordValid("51IZZ@6JWVE"));
System.out.println(new PasswordStrengthValidatorHelper().passwordStrength("111"));
}
}
测试结果
37.0
91298600
0
111
[再多加几个字符,不要添加常见字符。, 避免重复的单词和字符。]
com.nulabinc.zxcvbn.AttackTimes$CrackTimesDisplay@6ea6d14e
com.nulabinc.zxcvbn.Strength@ea4a92b
4、关键业务流程
略
❑
用户界面
1、成品演示
https://www.toolsoh.com/p/t/life/mimashengchengqi-passwordgenerator.html
2、界面展示
❑
致谢开源
-
开源项目作者:
nulab
-
开源项目名称:
zxcvbn4j
-
开源项目地址:
https://github.com/nulab/zxcvbn4j
去star
-
开源项目描述:
这是zxcvbn的一个java端口,是一个JavaScript密码强度生成器。This is a java port of zxcvbn, which is a JavaScript password strength generator.
❑
END
版权声明:本文为billionrong原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。