By Yash Singh
This is a project on random password generator using random() method in Java. Just give the length of the password you want to generate.
Hello folks,
This project is about creating a random password generator using random() method of Math class in Java. You just give the length of the password you want to generate and you'll get a random password of that length.
The user needs to enter the length of the password to be generated.
The password is created using the random() method which generates/selects a random numbers or elements. A string named passwordSet containing uppercase and lowercase letters (A-Z and a-z), numbers (0-9) and special symbols (!, @, #, $, %, ^, &, *,+) was created and the random() function called which generates a random number between 0 and length of passwordSet and the character present at this random index is picked from the psswordSet string and added to our password and this was repeated number of times till full password is generated.
About random() method in java :
The java.lang.Math.random() method returns a pseudorandom double type number greater than or equal to 0.0 and less than 1.0. When this method is first called, it creates a single new pseudorandom-number generator.
Syntax :
public static double random()
Submitted by Yash Singh (singhyash689)
Download packets of source code on Coders Packet
Comments