- 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
廣告