ToolsOhの密码强度检查(KT:java、zxcvbn、passay)

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

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值