Package com.oovever.util;
Import Java.util.Date;
Import Java.util.Random; /** * Password Tool class * @author Oovever * 2018/1/14 23:58 * * public class Passwordutil {//define the characters that can be used public final stat IC string[] Word= {"A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M", "N", "P", "Q", "R", "s", "T", "U", "V", "w", "X", "Y", "Z", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "M",
"N", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; Defines the number public final static string[] num that can be used= {"2", "3", "4", "5", "6", "7", "8", "9"}; /** * Randomly generated password * @return Returns the randomly generated password/public static string Randompassword () {StringBuffer string Buffer= New StringBuffer (); Random Random= New Random (New Date (). GetTime ()); Random out number or character Boolean flag= False Random out of the length that can be used int= Random.nextint (3)+ 8; for (int i= 0; I<Length I++{//flag is true to randomly give a number if (flag) {Stringbuffer.append (Num[random.nextint Num.leng
TH)]);
else {//random out one character stringbuffer.append (Word[random.nextint (word.length))); }//Guaranteed password flag between characters and numbers= !Flag
return stringbuffer.tostring ();
public static void Main (string[] args) throws Exception {System.out.println ());
Thread.Sleep (100);
System.out.println (Randompassword ());
Thread.Sleep (100);
System.out.println (Randompassword ());
}
}