JAVA-generated random password __java-util with alternating character numbers

Source: Internet
Author: User
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 ());
 }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.