0
how to generate password?
1 Antwort
0
https://code.sololearn.com/cfyVDc1nMf5a/#java
import java.util.Random;
public class PasswordGenerator
{
public static void main( String[] args )
{
generatePassword( 8 );
}
static Random rnd = new Random();
static void generatePassword( int characterLength )
{
// Characters to use in the password
// Formatted to be able to quickly comment/uncomment upper-case, lower-case, numbers and symbols as needed
String characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "1234567890"
//+ "!£$%^&*()"
;
String password = "";
for ( int i = 0; i < characterLength; i++ ) {
password += characters.charAt( rnd.nextInt( characters.length() ) );
}
System.out.println( password );
}
}