- Passay 教程
- Passay − 主页
- Passay − 概述
- Passay − 环境设置
- 验证/生成
- Passay − 密码验证
- Passay − 自定义消息
- Passay − M 个 N 条规则
- Passay − 密码生成
- 正向匹配规则
- passay − AllowedCharacterRule
- Passay − AllowedRegexRule
- Passay −CharacterRule
- passay − LengthRule
- Passay − CharacterCharacteristicsRule
- Passay − LengthComplexityRule
- 负向匹配规则
- Passay − lllegalCharacterRule
- Passay − NumberRangeRule
- Passay − WhitespaceRule
- Passay − DictionaryRule
- Passay − DictionarySubstringRule
- Passay − HistoryRule
- passay − RepeatCharacterRegexRule
- Passay − usernameRule
- Passay 实用资源
- Passay - 快速指南
- Passay - 资源
- Passay - 讨论
Passay - 密码生成
PasswordGenerator 帮助使用给定策略生成密码。考虑以下策略
密码长度应为 8 个字符。
密码应包含以下每个字符:大写、小写、数字和符号。
示例
以下示例显示了如何使用 Passay 库根据上述策略生成密码。
import org.passay.CharacterRule;
import org.passay.EnglishCharacterData;
import org.passay.PasswordGenerator;
public class PassayExample {
public static void main(String[] args) {
CharacterRule alphabets = new CharacterRule(EnglishCharacterData.Alphabetical);
CharacterRule digits = new CharacterRule(EnglishCharacterData.Digit);
CharacterRule special = new CharacterRule(EnglishCharacterData.Special);
PasswordGenerator passwordGenerator = new PasswordGenerator();
String password = passwordGenerator.generatePassword(8, alphabets, digits, special);
System.out.println(password);
}
}
输出
?\DE~@c3
广告