How To Make A Password Generator In Java

generate


hello today i am going to teach you to create a password generator in java first of all make sure you read this - http://ultimateprogrammingtutorials.blogspot.com/2013/02/starting-with-java-programming.html ok now what this program will do is we have string alphabets now when we run the program it will generate a password by the way this is not a GUI program so now here is the code

/** 
 * Author : Mohamed Shimran
 * Blog : http://www.ultimateprogrammingtutorials.blogspot.com
 */
public class Generator {

 public static void main(String[] args) {
               
         //alphabet//      
        String alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789<>?/;:/*-+.#$%^&£!";
        int i = 0;
        int Alphalaenge = alphabet.length();
       
        while(i < 15){
                int rand = (int) (Math.random() * Alphalaenge);
            System.out.print(alphabet.charAt(rand));
            ++i;
        }
        }
}

Generator is the class and string alphabet is the strings used to generate the password

when you debug it will generate a password like this one

password java

any problems ?? just comment below

4 comments

characters are displaying vertically not as string.

Reply

why is it telling me that rand is incompatable types

Reply

how to generate a password with input 1 as "david",and input 2 as "523" and output should be as 1@9d(password)->created from tens place of 2 along ????????????????????????????

Reply

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training in Chennai

Reply

Post a Comment

Note: Only a member of this blog may post a comment.