直播軟體開發,隨機密碼生成器
直播軟體開發,隨機密碼生成器
方法呼叫
public static void main(String[] args) { //排除字元0OoB81lI ,包含大寫字母,包含小寫字母,包含數字,包含特殊字元,長度8,生成10000個,特殊字符集 generatePassword("0OoB81lI",true,true,true,true,8,10000,"~!@^*%"); }
附帶密碼檢測器
檢測生成的密碼是否合格
private static void checkPasswordIsCorrect(){ File file = new File("C:\\Users\\1002212\\Desktop\\445566.txt"); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String tempString ; int line = 1; // 一次讀入一行,直到讀入null為檔案結束 while ((tempString = reader.readLine()) != null) { // 顯示行號 if(!tempString.matches("^[0-9A-Za-z~!@^*#$%]{8}$")){ System.out.println("line " + line + ": " + tempString); } if(!tempString.matches(".*[0-9]+.*") || !tempString.matches(".*[A-Z]+.*") || !tempString.matches(".*[a-z]+.*") || !tempString.matches(".*[~!@^*#$%]+.*")){ System.out.println("line " + line + ": " + tempString); } line++; } reader.close(); } catch (Exception e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (Exception e1) { e1.printStackTrace(); } } } }
以上就是 直播軟體開發,隨機密碼生成器,更多內容歡迎關注之後的文章
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2985690/,如需轉載,請註明出處,否則將追究法律責任。