การคัดลอกรหัสมีดังนี้:
แพ็คเกจ com.phyl.password;
นำเข้า java.util.arraylist;
นำเข้า Java.util.Arrays;
นำเข้า java.util.random;
-
* คลาสที่สร้างขึ้นแบบสุ่มคลาส
* @author Asus
-
-
รหัสผ่านระดับสาธารณะ {
-
* การแจกแจงประเภทรหัสผ่าน
* @author Asus
-
ชนิด enum สาธารณะคงที่ {
-
* ประเภทอักขระ
-
จดหมาย,
-
*ประเภทอักขระตัวพิมพ์ใหญ่
-
เมืองหลวง,
-
* ประเภทดิจิตอล
-
ตัวเลข,
-
* ประเภทสัญลักษณ์
-
เข้าสู่ระบบ,
-
* ประเภทตัวละครขนาดใหญ่ + ขนาดเล็ก
-
Letter_capital
-
* อักขระขนาดเล็ก + ตัวเลข
-
ตัวอักษร _number
-
* ตัวละครขนาดใหญ่ + ขนาดเล็ก + ประเภทตัวเลข
-
Letter_capital_number
-
* ตัวอักษรขนาดใหญ่ + ขนาดเล็ก + ตัวเลข + สัญลักษณ์
-
Letter_capital_number_sign
-
สตริงคงที่ส่วนตัว [] ตัวพิมพ์เล็ก = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x "," y "," z "};
สตริงคงที่ส่วนตัว [] Capital = {
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x "," y "," z "};
สตริงคงที่ส่วนตัว [] number = {
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"};
สตริงคงที่ส่วนตัว [] sign = {
"~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "_", "+ "," `", "-", "=",
-
-
-
* หมายเลขสุ่มคงที่
-
สุ่มแบบคงที่ส่วนตัวแบบสุ่ม = ใหม่สุ่ม ();
โมฆะคงที่สาธารณะหลัก (สตริง [] args) {
System.out.println (password.getRandom (24, password.type.capital));
-
-
* รับรหัสชุดค่าผสมแบบสุ่ม
* @param จำนวนตัวเลขตัวเลข
* @param ประเภท
* @พิมพ์
* <br> ตัวอักษรตัวอักษร
* <br> ทุน
* <br> หมายเลข
* <br> สัญลักษณ์สัญลักษณ์
* <br> Letter_capital
* <br> อักขระขนาดเล็ก + ตัวอักษรตัวเลข _number
* <br> ตัวอักษรขนาดใหญ่ + ขนาดเล็ก + ตัวเลข letter_capital_number,
* <br> ตัวอักษรขนาดใหญ่ + ขนาดเล็ก + ตัวเลข + ตัวอักษรสัญลักษณ์ _capital_number_sign
-
สตริงคงที่สาธารณะ getRandom (int num, ประเภทประเภท) {
ArrayList <String> temp = new ArrayList <String> ();
StringBuffer Code = new StringBuffer ();
if (type == type.letter) {
temp.addall (array.aslist (ตัวพิมพ์เล็ก));
} อื่นถ้า (type == type.capital) {
temp.addall (array.aslist (ทุน));
} อื่นถ้า (type == type.number) {
temp.addall (array.aslist (หมายเลข));
} อื่นถ้า (type == type.sign) {
temp.addall (array.aslist (ป้าย));
} อื่นถ้า (type == type.letter_capital) {
temp.addall (array.aslist (ตัวพิมพ์เล็ก));
temp.addall (array.aslist (ทุน));
} อื่นถ้า (type == type.letter_number) {
temp.addall (array.aslist (ตัวพิมพ์เล็ก));
temp.addall (array.aslist (หมายเลข));
} อื่นถ้า (type == type.letter_capital_number) {
temp.addall (array.aslist (ตัวพิมพ์เล็ก));
temp.addall (array.aslist (ทุน));
temp.addall (array.aslist (หมายเลข));
} อื่นถ้า (type == type.letter_capital_number_sign) {
temp.addall (array.aslist (ตัวพิมพ์เล็ก));
temp.addall (array.aslist (ทุน));
temp.addall (array.aslist (หมายเลข));
temp.addall (array.aslist (ป้าย));
-
สำหรับ (int i = 0; i <num; i ++) {
code.append (temp.get (random.nextint (temp.size ())));
-
รหัสส่งคืน toString ();
-
-