This post contains a total of 43+ Hand-Picked Java password generator examples. All the password generators are made purely using Java programming language.
You can use the source codes of these java password generators for educational use with credits to the original owner. In case you need the source code for some other use then you should contact the owner for it.
Related Posts
Click a Code to Copy it, and Hover over a video to play it.
1. By Robotter112
Java Password generator by Robotter112. The program generates a random 10 digit password. ( Source )
import java.util.Random;
// By Robotter112
// YouTube: Robotter112
public class PasswordGenerator
{
public static void main(String[] args)
{
int length = 10; // password length
System.out.println(generatePswd(length));
}
static char[] generatePswd(int len)
{
System.out.println("Your Password:");
String charsCaps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String chars = "abcdefghijklmnopqrstuvwxyz";
String nums = "0123456789";
String symbols = "[email protected]#$%^&*_=+-/€.?<>)";
String passSymbols = charsCaps + chars + nums + symbols;
Random rnd = new Random();
char[] password = new char[len];
int index = 0;
for (int i = 0; i < len; i++)
{
password[i] = passSymbols.charAt(rnd.nextInt(passSymbols.length()));
}
return password;
}
}
2. By Zekki__
Made by Zekki__. The program generates a random 10 digit password using numbers and alphabets. ( Source )
import java.util.Random;
class MyClass {
public static void main(String[] args) {
Random r = new Random();
String z = "[email protected]";
for (int i = 0; i < 10; i++) {
System.out.print (z.charAt(r.nextInt(z.length())));
}
}
}
3. By Lavanya
Made by Lavanya. Enter password length to get a random password containing symbols, numbers and alphabets. ( Source )
// created by lavanya
// this code generates a password of required length as output.
// entered a number = length of the password
// so enter a number to get required password
import java.util.*;
public class Main
{
char[] password(int n){
char [] a=new char[n];
String s="0123456789";
String p="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String t="abcdefghijklmnopqrstuvwxyz";
String q="[email protected]#$%^&*~";
String j=s+p+t+q;
Random r=new Random();
for(int i=0;i<n;i++)
{
a[i]=j.charAt(r.nextInt(j.length()));
}
return a;
}
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
int length=input.nextInt();
Main o =new Main();
System.out.println(o.password (length));
}
}
4. By Seniru
Made by Seniru. Enter any number between 8 and 32 to generate a random password. ( Source )
import java.util.*;
public class PasswordGenerator {
static Random r = new Random();
public static String generate(int l) {
return l<8||l>32?"Error: Entered number for the password generator is out of range":String.join("",r.ints(l,33,126).mapToObj(x->Character.toString((char)x)).toArray(String[]::new));
}
public static void main(String[] args) {
var c = new Scanner(System.in).nextInt();
System.out.println("Entered number: "+c+"\nGenerated random password: "+generate(c));
}
}
5. By Gaurav Agrawal
Made by Gaurav Agrawal. Enter length of password required. ( Source )
/*
*Author : Gaurav Agrawal
*Created on 30th january 2018
*/
import java.util.*;
//Random,Scanner
public class GauravProgram
{
static int g=0;
public static void main(String[] args)
{
System.out.println(gnrtPsd(new Scanner(System.in).nextInt()));
}
static String gnrtPsd(int ln)
{
String ps="[email protected]#$%^&*abcdefghijklmnopqrstuvwxyz";
return (ln>g++)?ps.charAt(new Random().nextInt(68))+gnrtPsd(ln):"";}
}
6. By Terrence Lee
Java password generator by Terrence Lee. Generates a random 10 digit password. ( Source )
//Author: Terrance
import java.util.Random;
public class PasswordGenerator
{
public static void main(String[] args)
{
int length = 10; // password length
System.out.println(generatePswd(length));
}
static char[] generatePswd(int len)
{
System.out.println("Your Password:");
String passSymbols = "[email protected]#$%^&*_=+-/€.?<>)[];^#";
Random rnd = new Random();
char[] password = new char[len];
for (int i = 0; i < len; i++)
{
password[i] = passSymbols.charAt(rnd.nextInt(passSymbols.length()+1));
}
return password;
}
}
7. By Bibi Fire
Made by Bibi Fire. Enter password length to generate a random password containing alphabets, numbers and symbols. ( Source )
import java.util.Scanner;
import java.math.BigInteger;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Program
{
public static String getAlphaNumericString(int n)
{
// chose a Character random from this String
String alphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789"
+ "abcdefghijklmnopqrstuvxyz"
+ "!\"#$%&\'()*+,-./:;<=>[email protected][\\]^_`{|}~§€£¥’‘`";
// create StringBuffer size of AlphaNumericString
StringBuilder sb = new StringBuilder(n);
for (int i = 0; i < n; i++) {
// generate a random number between
// 0 to AlphaNumericString variable length
int index
= (int)(alphaNumericString.length()
* Math.random());
// add Character one by one in end of sb
sb.append(alphaNumericString.charAt(index));
}
return sb.toString();
}
public static void main(String[] args) {
try {
Scanner scn = new Scanner(System.in);
System.out.println("Enter password lenght");
// Get password lenght
String reader = scn.nextLine();
// Check if there is a non numerical input
Pattern p = Pattern.compile("\\D+");
Matcher m = p.matcher(reader);
if(m.find()) {
System.out.println("Error, you entered letters" );
return;
}
/*BigInteger maxInt = BigInteger.valueOf(Integer.MAX_VALUE);
BigInteger value = new BigInteger(BigInteger.parseInt(reader));
if (value.compareTo(maxInt) > 0)
{
System.out.println("You entered a too big number !");
return;
}*/
Integer i = Integer.parseInt(reader);
// Check if the input is 0
if(i.equals(0)) {
System.out.println("Error, you cannot generate a password with a lenght of 0" );
return;
}
// Output the password
System.out.println("Here is your password : \n" + getAlphaNumericString(i));
} catch(Exception exeption) {
exeption.printStackTrace();
}
}
}
8. By hamid
Made by hamid. It Generates a random 15 digits password. ( Source )
import java.util.Random;
public class PasswordGenerator
{
public static void main(String[] args)
{
int length =15;
System.out.println(generatePwd(length));
}
static char[] generatePwd(int len)
{
System.out.println("Your Password:");
String charsCaps = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String chars = "abcdefghijklmnopqrstuvwxyz";
String nums = "0123456789";
String symbols = "[email protected]#$%^&*_=+-/€.?<>)";
String math = "⅙½¾⁶⁷⁸⁹⅘¾⅜⅗⅔⅖⅕⅒⅑";
String nam = "★†‡«»‹›¡¿‽№€¢£¥₱—–±♣♠♪♥♦ΩΠμ§¶∆^°©®™✓";
String passSymbols = nam + math + charsCaps + chars + nums + symbols;
Random rnd = new Random();
char[] password = new char[len];
int index = 0;
for (int i = 0; i < len; i++)
{
password[i] = passSymbols.charAt(rnd.nextInt(passSymbols.length()));
}
return password;
}
}
9. By Tapabrata Banerjee
Made by Tapabrata Banerjee. It Generates a random password between 10 to 20 characters’ length. ( Source )
/*
It may contain uppercase or lowercase alphabets, numbers,. (dot) or $ (dollar sign)
My YouTube channel:
https://wwww.youtube.com/c/TapabratasTechTalks
*/
public class Program
{
public static void main(String[] args)
{
char ch, a;
System.out.print("Your password is: \n");
int l = (char)((int)((Math.random()*(20-10))+10));
for (int x =1; x<=l;x++)
{
a = (char)((int)(Math.random()*(5-1)+1));
switch(a)
{
case 1:
ch=(char)((int)((Math.random()*(57-48))+48));
break;
case 2:
ch=(char)((int)((Math.random()*(90-65))+65));
break;
case 3:
ch=(char)((int)((Math.random()*(122-97))+97));
break;
case 4:
ch=46;
break;
case 5:
ch=36;
break;
default:
ch='a';
}
System.out.print(ch);
}
}
}
10. By AJ
Made by AJ. Enter a password length between 5 – 20 to get a random password. ( Source )
import java.util.*;
public class PasswordGenerator
{
public static final String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!`[email protected]#$%^&*()-_=+?><;'";
public static final String LETTERCHAR = "abcdefghijkllmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
if(num > 20 || num < 5) {
System.out.println("Max Password length is 20 and min is 5 !");
return;
}
System.out.println("Password Type 1 = " + generateString(num));
System.out.println("Password Type 2 = " + generateMixString(num));
System.out.println("Password Type 3 = " + generateLowerString(num));
System.out.println("Password Type 4 = " + generateUpperString(num));
}
public static String generateString(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));
}
return sb.toString();
}
public static String generateMixString(int length) {
StringBuffer sb = new StringBuffer();
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(ALLCHAR.charAt(random.nextInt(LETTERCHAR.length())));
}
return sb.toString();
}
public static String generateLowerString(int length) {
return generateMixString(length).toLowerCase();
}
public static String generateUpperString(int length) {
return generateMixString(length).toUpperCase();
}
}
11. By DeathWhisper
Made by DeathWhisper. Enter password length between 8 – 16 to generate a random password. ( Source )
import java.util.*;
public class passwordGenerator {
public static void main(String[] args) {
Scanner scn = new Scanner(System.in);
int length = scn.nextInt();
int zero = 26;
int one = 26;
int two = 10;
int three = 9;
if(length >= 8 & length <= 16) {
String l = "abcdefghijklmnopqrstuvwxyz";
String u = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String n = "0123456789";
String s = "@#$%*/^-+";
ArrayList<String> password = new ArrayList<>();
ArrayList<String> lower = new ArrayList<>();
ArrayList<String> upper = new ArrayList<>();
ArrayList<String> num = new ArrayList<>();
ArrayList<String> spec = new ArrayList<>();
char[] lo = l.toCharArray();
char[] up = u.toCharArray();
char[] nu = n.toCharArray();
char[] sp = s.toCharArray();
for(int i = 0; i < 26; i++) {
String x = "" + lo[i];
String y = "" + up[i];
lower.add(x);
upper.add(y);
}
for(int i = 0; i < 10; i++) {
String x = "" + nu[i];
num.add(x);
}
for(int i = 0; i < 9; i++) {
String x = "" + sp[i];
spec.add(x);
}
System.out.print("Password: ");
for (int i = 0; i < length; i++){
int x = random(4);
if (x == 0 & zero != 0) {
addToPassword(password, lower, zero);
zero--;
}
if (x == 1 & one != 0) {
addToPassword(password, upper, one);
one--;
}
if (x == 2 & two != 0) {
addToPassword(password, num, two);
two--;
}
if (x == 3 & three != 0) {
addToPassword(password, spec, three);
three--;
}
System.out.print(password.get(i));
}
}
else if(length < 8) System.out.println("too short");
else System.out.println("too long");
}
public static int random(int num){
return (int) (Math.random() * num);
}
public static void addToPassword(ArrayList<String> password, ArrayList<String> type, int num){
int y;
y = random(num);
password.add(type.get(y));
type.remove(y);
}
}
12. By Oleg Berezhnoy
Java password generator by Oleg Berezhnoy. Enter password length you want to generate, there is no limit to password length. ( Source )
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;
import java.util.Scanner;
/**
* Password Generator.
*
* This program accepts the password's length as an input.
* And generates password with desired length with conditions:
*
* 1. At least 8 characters long
* 2. Consists of digits, uppercase and lowercase letters and characters
*/
public class PasswordGenerator {
public static void main(String[] args) {
System.out.println("Password generator.");
Scanner scanner = new Scanner(System.in);
int length = 0;
while (length < 8) {
System.out.print("Please enter your password's length (8 and above): ");
try {
length = scanner.nextInt();
if (length < 8)
System.out.println("Password should be at least 8 characters long! Try again!");
} catch (InputMismatchException e) {
System.out.println("Please enter valid number!");
scanner.next();
}
}
// random variable for generators
Random random = new Random();
// char array for password
char[] password = new char[length];
/*
flags array. This array has an element for every group of symbols:
flags[0] - digits
flags[1] - uppercase letters
flags[2] - lowercase letters
flags[3] - characters
(1 - password has a symbol from the group in it, 0 - password doesn't have a symbol from the group)
*/
int[] flags = new int[4];
while (!Arrays.toString(flags).equals("[1, 1, 1, 1]")) {
for (int count = 0; count < password.length; count++) {
switch (random.nextInt(4)) {
case 0: //digits 0-9 char 48-57
password[count] = (char) (random.nextInt(10) + 48);
flags[0] = 1;
break;
case 1: //uppercase A-Z char 65-90
password[count] = (char) (random.nextInt(27) + 65);
flags[1] = 1;
break;
case 2: //lowercase a-z char 97-122
password[count] = (char) (random.nextInt(27) + 97);
flags[2] = 1;
break;
case 3: //characters !-/ char 33-47
password[count] = (char) (random.nextInt(16) + 33);
flags[3] = 1;
break;
}
}
}
System.out.print("\nHere's your password: ");
for (char c : password) {
System.out.print(c);
}
}
}
13. By Jahnics
Made by Jahnics. Enter password length to generate a random password. ( Source )
public class Program
{
public static void main(String[] args) {
String word = new java.util.Scanner(System.in).next();
System.out.println("The password for " + word + " is \n" + password(word));
}
public static String password(String input) {
String output = "", s = input;
input = input.length() < 5? input:input.substring(0, 5);
for (int i = 0; i < input.length(); i++) {
output += (char)((input.charAt(i) + (Math.pow(-1, i) * 5)) % (input.charAt(i) > 'z'? 'Z':'z') + 'a');
}
output += "" + s.length();
output += ("" + (char)(s.charAt(s.length()-1) - 'z' + 'a')).toLowerCase();
output += ("" + (char)(input.length() % 10 + 'b')).toUpperCase();
output += (char)('9' + (input.length() % 9));
for (int x = 0; output.length() < 8; x++) {
output += (char)(output.charAt(x) % 100);
}
return output;
}
}
14. By Atharv Srivastava
Made by Atharv Srivastava. Enter password length between 8 – 32 for a random password. ( Source )
import java.util.*;
public class Password_Generator
{
static String pass="";
static char ch;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
System.out.println("Your input length:"+n);
if(n<8){
n=8;
System.out.println("Minimum length is 8:");
}
if(n>32) {
n=32;
System.out.println("Maximum length can be 32");
}
for(int i=1;i<=n;i++){
ch=(char)(Math.round(33+84*Math.random()));
pass+=ch;
}
System.out.print(pass);
}
}
15. By smaznet
Made by smaznet. Enter password length you want to generate a random password containing alphabets, numbers and symbols. ( Source )
import java.lang.*;
import java.util.*;
public class Program
{
private static String allchars="[email protected]#%*_&!?";
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
System.out.println("Write password length and hit [ENTER]");
int lentgh=scanner.nextInt();
System.out.println(generatePass(lentgh ));
}
public static String generatePass(int lentgh){
String pass="";
for(int i=0;i<lentgh;i++){
pass +=allchars.charAt(new Random().nextInt(allchars.length()))+"";
}
return pass;
}
}
16. By Sumit Programmer
Made by Sumit Programmer. Enter password length between 8 – 32 for a random password. ( Source )
public class Program
{
String b;
static int c,d;
public void collect(char r)
{
System.out.print(r);
d--;
if(d!=0)
genrate();
}
public void genrate() // Method Chaning
{
if(c>=8&&c<=32&&d!=0)
{
collect((char)((int)(Math.random()*(126-33)+33)));
}
else
{
System.out.println("your input length must between 8 to 32");
}
}
public static void main(String[] args) {
c=new java.util.Scanner(System.in).nextInt();
d=c;new Program().genrate();
}
}
17. By Eliya Ben Baruch
Made by Eliya Ben Baruch. The program Generates a random 8 digits password. ( Source )
public class Program
{
public static void main(String[] args) {
String password = "";
char currentChar;
while (password.length() < 8){
currentChar = (char) (Math.random() * 94 + 33);
password += password.indexOf(currentChar) == -1 ? currentChar : "";
}
System.out.println(password);
}
}
18. By Programmistic
Made by Programmistic. The program generates a random 12 digits password. You can change the password length by changing the ‘int len = rand.nextInt(8) + 5;’ line. ( Source )
import java.util.*;
public class Password
{
public static void main(String[] args) {
Random rand = new Random();
String ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String [ ] ABCArr = ABC.split("");
String abc = "abcdefghijklmnopqrstuvwxyz";
String [ ] abcArr = abc.split("");
String nums = "0123456789";
String [ ] numsArr = nums.split("");
String sym = "[email protected]#№$%&?*";
String [ ] symArr = sym.split("");
int len = rand.nextInt(8) + 5; //password length (from 5 to 12)
int AaNS; //ABC or abc or Nums or Sim
for(int i = 0; i < len; i++){
AaNS = rand.nextInt(7) + 1;
switch(AaNS){
case 1: System.out.print(ABCArr[rand.nextInt(ABCArr.length)]); break;
case 2: System.out.print(ABCArr[rand.nextInt(ABCArr.length)]); break;
case 3: System.out.print(abcArr[rand.nextInt(abcArr.length)]); break;
case 4: System.out.print(abcArr[rand.nextInt(abcArr.length)]); break;
case 5: System.out.print(numsArr[rand.nextInt(numsArr.length)]); break;
case 6: System.out.print(numsArr[rand.nextInt(numsArr.length)]); break;
case 7: System.out.print(symArr[rand.nextInt(symArr.length)]); break; //$YMB0L$ is bad
}
}
}
}
19. By Antonio Sciannella
Made by Antonio Sciannella. Enter password length to generate a random password containing alphabets, numbers and symbols. ( Source )
import java.util.Random;
import java.util.Scanner;
public class PasswordGenerator
{public static void main(String[] args)
{
Scanner scan= new Scanner(System.in);
int length ; //password length
length = scan.nextInt(); System.out.println(generatePswd(length));}
static char[] generatePswd(int len)
{System.out.println("Your Password:");
String passSymbols = "[email protected]#$%^&*_=+-/€.?<>)";
Random rnd = new Random();
char[] password = new char[len];
for (int i=0;i<len;i++){password[i]=passSymbols.charAt(rnd.nextInt(passSymbols.length()));}
return password;}}
20. By Sharath
Java password generator by Sharath. Generates a random 12 digits password. ( Source )
import java.util.*;
class Pas{
public static void main(String []args){
char ch[]=new char[128];
Random R=new Random();
System.out.println("Your Password.");
for(int i=0;i<12;++i){
ch[i]=(char)R.nextInt(128);
System.out.print(ch[i]);
}
}
}
21. By benyamin radmard
Made by benyamin radmard. Enter password length between 3 – 100 to generate a random password. ( Source )
import java.util.Random;
import java.util.Scanner;
public class PasswordGenerator {
private static char [] chars ={'!','"','$','%','&','/'
,'(',')','=','?','<','>','@','{','}','[',']','\\','|',';'};
private static char [] SAlphas ={'a','b','c','d','e','f','g','h','i','j',
'k','m','l','m','n','o','p','q','r','s',
't','u','x','w','y','z'};
private static char [] BAlphas ={'A','B','C','D','E','F','G',
'H','I','J','K','L','M','N','O','P','Q'
,'R','S','T','U','X','W','Y','Z'};
private static char [] nums ={'1','2','3','4','5','6','7','8','9','0'};
public static void main(String[] args) {
getInput();
}
private static void getInput(){
Scanner s = new Scanner(System.in);
ShowMessage("Please enter length of your password"+"\n");
int lenght = s.nextInt();
if (lenght > 3 && lenght < 100){
generatePassword(lenght);
}else if (lenght <= 3){
ShowMessage("Your input is less than 3"+"\n");
getInput();
}else if (lenght >= 100){
ShowMessage("Your input is greater than 100"+"\n");
getInput();
}
}
private static void ShowMessage(String s){
System.out.println(s);
}
private static void generatePassword(int length){
for (int x =0; x <= length;x++){
chose();
}
}
private static void chose(){
int num = makeRandom();
switch (num){
case 0:take(chars);break;
case 1:take(SAlphas);break;
case 2:take(BAlphas);break;
case 3:take(nums);break;
}
}
private static int makeRandom(){
Random r = new Random();
return r.nextInt(4);
}
private static void take(char [] array){
Random r = new Random();
int num = r.nextInt(array.length);
System.out.print(array[num]);
}
}
22. By Kafeelur Rahman T K
Made by Kafeelur Rahman T K. Enter password length to generate, there is no limit to password length. ( Source )
import java.util.Random;
import java.util.Scanner;
public class PasswordGenerator{
int length;
Random rand;
String password;
public PasswordGenerator(int length){
this.length=length;
rand=new Random();
password = generate();
System.out.println("Password Length : "+length);
System.out.println("Generated Password: \n"+password);
}
private String generate(){
char c[]=new char[length];
String generated="";
int r=0;
String pass="[email protected]#_&-+(/*:.%='~|€[{}];!?$£)";
for(int i=0;i<length;i++){
r=rand.nextInt(pass.length());
c[i]=pass.charAt(r);
}
for(int i=0;i<length;i++){
generated+=""+c[i];
}
return generated;
}
}
public class MainClass
{
static Scanner sc;
public static void main(String[] args) {
System.out.println("Enter a length of a password: ");
sc=new Scanner(System.in);
int length=sc.nextInt();
PasswordGenerator obj;
if(length > 4)
obj=new PasswordGenerator(length);
else
System.out.println("Password Length Should be more than 4.");
}
}
23. By Douglas H
Made by Douglas H. The program generates a random 11 digits password. ( Source )
import java.util.Random;
public class Program
{
public static void main(String[] args) {
String symbols = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#¤%&/()[email protected]£${[]}";
Random rand = new Random();
for(int x=0; x<=10; x++){
int randomnumber = rand.nextInt(symbols.length());
System.out.print(symbols.charAt(randomnumber));
}
}
}
24. By Error programm
Made by Error programm. The program generates a random 7 digits password of numbers and alphabets. ( Source )
public class Password
{
public static void main(String[] args) {
String[]abcd={"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"};
System.out.println("Random password: ");
for (int s=0;s<7;s++)
{
double RAND=Math.ceil(Math.random()*2);
int RANDD=(int)RAND;
if(RANDD==1)
{
double ab = Math.ceil(Math.random() * 25);
int abb=(int)ab;
System.out.print (abcd[abb]);
}
if(RANDD==2)
{
double r= Math.ceil(Math.random() * 10-1);
int rand=(int) r;
System.out.print(rand);
}
}
}
}
25. By AgusNico
Made by AgusNico. Enter password length between 6 – 15 to generate a random password. ( Source )
import java.util.Scanner;
public class Random
{
public static String pickRandom(String[] array) {
double randomNumber = Math.floor(Math.random() * array.length);
return array[(int) randomNumber];
}
}
public class PswGenerator
{
static String input = new Scanner(System.in).nextLine();
public static boolean validation() {
try {
int n = Integer.parseInt(input);
return true;
} catch (Exception e) {
return false;
}
}
static boolean numberVal = PswGenerator.validation();
static String[] characters = {"a","b","c","d","e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
static String[] symbols = {"#", "%", "@", "/", "&", "€", "£", "$"};
static String res = "";
public static String gen() {
if(!numberVal) {
throw new IllegalArgumentException("Input should be a number");
}
int num = Integer.parseInt(input);
if(num >= 6 && num <= 15) {
for (int i = 0; i < num / 2; i++) {
res += Random.pickRandom(characters);
res += Random.pickRandom(symbols);
} } else {return "Password length must be between 6 and 15 characters";}
if (res.length() != num) {
res += Random.pickRandom(characters);
}
return res;
} }
public class Main
{
public static void main(String[] args) {
System.out.println(PswGenerator.gen());
}
}
26. By Vanshaj Nathani
Made by Vanshaj Nathani. Enter password length between 8 – 32 for a random password containing letters and symbols. ( Source )
import java.util.*;
public class passwordgenerator
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
Random rand=new Random();
int x;
char ch;
String password="";
System.out.print("Enter length of your password:");
x=sc.nextInt();
if(x>7&&x<33)
{
for(int y=0;y<x;y++)
{
int z=33+rand.nextInt(93);
ch=(char)(z);
password+=ch;
}
System.out.println("\n"+password);
}
else
System.out.println("\n"+"Length should be between 8 & 32 only");
}}
27. By Thomas Kraemer
Java password generator by Thomas Kraemer. Enter password length for random password, enter length between 8 – 32. ( Source )
import java.util.Scanner;
import java.util.Random;
public class PasswordGenerator{
public static void main(String args[]){
// Create a Scanner Instance to get user input
Scanner input = new Scanner(System.in);
System.out.println("Enter a password length between 8 and 32 \n");
//Assigning user input from Scanner to variable
int passlength = input.nextInt();
//Check if users password length is between 8 and 32
if (passlength > 7 && passlength < 33){
//Confirming Input
System.out.println("You haven chosen "+passlength + " as your password length.");
//The try catch block is neccessary to catch a NullPointer Exception
//that is thrown when the password is not secure. The generated passwords
//are tested if they contain Caps, lowercase, numbers and symbols at least once.
//If not the generatePassword() function returns null and the program starts over.
try {
//Call generatePassword() and Print the returned pass
System.out.println(generatePassword(passlength));
}
catch ( Exception e ) {
//If generated password isnt secure a null pointer is returned.
//This causes an Exception tht is catched by simply generating
//another password with a new call of generatePassword()
//YES I KNOW! BAD CODING! Potential Infinite Loop....
System.out.println(generatePassword(passlength));
}
}
else{
//If the user enters a value that is too small or too large we print this reminder...
System.out.println("Please try again with a password length of 8 to 32 !");
//and exit the program
System.exit(0);
}
}
//This is the actual function that generates the password
static char[] generatePassword(int passwordlength){
System.out.print("Your password is: \n");
boolean capsUsed = false;
boolean lowercaseUsed = false;
boolean numbersUsed = false;
boolean symbolsUsed = false;
int i;
String chars = "";
char[] password = new char[passwordlength];
//The for loop builds the password, one char at a time until it has the required length
for (i=0; i<passwordlength; i++){
//Using java.util.Random to generate random numbers
Random rand = new Random();
//creating a random number that can be 0, 1, 2, or 3
int selector = rand.nextInt(4);
//The switch selects one of the 4 character groups, depending on the random number
//that was just created and stored in "selector"
//When a character group is used a boolean value is set to true for that type
switch(selector){
case 0: chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
capsUsed = true;
break;
case 1: chars = "0123456789";
numbersUsed = true;
break;
case 2: chars = "abcdefghijklmnopqrstuvwxyz";
lowercaseUsed = true;
break;
case 3: chars = "[email protected]#$%^&*_=+-/.?<>)'(\"";
symbolsUsed = true;
break;
}
//Now that "chars" contains one of the 4 types of characters we pick a random
//character from "chars" and put it into "password"
password[i] = chars.charAt(rand.nextInt(chars.length()));
}
//After the loop has finished we have a password with the right amount of characters.
//But now we check if really all 4 different types of characters have been used
//Only if all 4 booleans have become true the password is returned to main() and gets printed
if (capsUsed == true && numbersUsed == true && lowercaseUsed == true && symbolsUsed == true){
return password;
}
//If the password doesnt contain all 4 types then null is returned...
//This leads to a null pointer exception. But the code in main will
//catch the exception and restart the program so it will run until it
//has created a secure password
else{
return null;
}
}
}
28. By Dallari Maicol
Made by Dallari Maicol. The program generates a random 10 digits password. ( Source )
import java.util.Random;
public class PasswordGenerator
{
public static void main( String[] args )
{
generatePassword( 10 );
}
static Random rnd = new Random();
static void generatePassword( int characterLength )
{
String characters =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "abcdefghijklmnopqrstuvwxyz"
+ "1234567890"
+ "!£$%^&*()@"
;
String password = "";
for ( int i = 0; i < characterLength; i++ ) {
password += characters.charAt( rnd.nextInt( characters.length() ) );
}
System.out.println( "Your password:\n"+password );
}
}
29. By Prabhakar Dev
Made by Prabhakar Dev. Enter length of the password you want to generate. No limit of password length. ( Source )
/*i would like to thank sean curry, one of the good people in the world because he pointed out an error in this program and helped me with it*/
import java.io.*;
public class Program
{
public static void main(String args[])throws IOException{BufferedReader r=new BufferedReader(new InputStreamReader(System.in));
int x=1;
long s;
String[] p={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0","@","#","$","%","&","-","+","*",":",";","!","?","="};
int l=Integer.parseInt(r.readLine());
if(l>=8){
for(x=1;x<=l;x++){
s=Math.round(Math.random()*48);
System.out.print(p[(int)s]);
}
}
}
}
30. By Sergei Khrapov
Made by Sergei Khrapov. Enter password length you want to generate, there is no limit to password length. ( Source )
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
char[] chars = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
System.out.print("Input your password length: ");
int input = new Scanner(System.in).nextInt();
System.out.println(input);
char[] password = new char[input];
for(int i = 0; i < input; i++){
int index = (int)(Math.random()*chars.length);
password[i] = chars[index];
}
System.out.println("Your password is:");
for(char passChar:password){
System.out.print(passChar);
}
}
}
31. By Magatte Diallo
Made by Magatte Diallo. Enter password length between 8 – 32 for a random password. ( Source )
import java.util.Random;
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
int i =0;
int lenght = 0;
String pwdGener = "";
String input = "";
boolean chk = false;
Scanner sc = new Scanner(System.in);
do{
System.out.println("Enter number between 8 and 32");
input = sc.nextLine();
chk = isNumeric(input);
if(chk){
lenght = Integer.parseInt(input);
if(lenght<8||lenght>32){
chk = false;
}
}
}while(chk == false);
if(chk){
while(i<lenght){
Random rand = new Random();
int nbalea = rand.nextInt(126-33)+33;
pwdGener = pwdGener.concat(pwdGener.valueOf((char)nbalea));
i++;
}
}
System.out.println("Input: "+input);
System.out.println("Output: "+pwdGener);
}
public static boolean isNumeric(String str){
try{
Integer.parseInt(str);
return true;
}catch(NumberFormatException e){
return false;
}
}
}
32. By Carlos
Made by Carlos. Enter password length to generate a random password containing numbers, alphabets and symbols. ( Source )
import java.util.Random;
import java.util.Scanner;
public class Program{
public static void main(String[] args){
Random r= new Random();
String s= "qwertyuiopasdfghjklzxcvbnm123456789%@~&/[{(<>)}]";
int x;
Scanner sc= new Scanner(System.in);
x= sc.nextInt();
for(int i=0;i<=x;i++){
System.out.print(s.charAt(r.nextInt(s.length())));
}
}
}
33. By Raphael Williams
Java password generator by Raphael Williams. ( Source )
import java.util.Scanner;
import java.util.Random;
public class Password
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int length = sc.nextInt();
sc.close();
System.out.println(new_Password(length));
}
static char[] new_Password(int len){
System.out.print("You new Password is: ");
String Capital_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String Small_chars = "abcdefghijklmnopqrstuvwxyz";
String numbers = "0123456789";
String symbols = "[email protected]#$%&*%";
String values = Capital_chars + Small_chars + numbers + symbols;
Random rnd_method = new Random();
char[] password = new char[len];
for(int i = 0; i < len; i++){
password[i] = values.charAt(rnd_method.nextInt(values.length()));
}
return password;
}
}
34. By MaxiZenit
Made by MaxiZenit. Enter password length for random password. ( Source )
import java.util.Scanner;
import java.util.Arrays;
import java.util.Random;
public class Program
{
public static void main(String[] args)
{
System.out.println("Enter the length of the password: ");
System.out.println(Password.generate((new Scanner(System.in)).nextInt()));
}
}
class Password
{
private static final String[] symbolsByIndexOfType = {"0123456789", "[email protected]#$%^&*()-_+=:,./?\\|`~[]{}", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
public static String generate(int passwordLength)
{
String password = "";
int randomNumber;
Random random = new Random();
int[] symbolsCountByIndexOfType = new int[4];
setSymbolsCount(symbolsCountByIndexOfType, passwordLength);
while (password.length() < passwordLength)
{
do
{
randomNumber = random.nextInt(symbolsByIndexOfType.length);
}while (symbolsCountByIndexOfType[randomNumber] == 0);
symbolsCountByIndexOfType[randomNumber]--;
password += generateChar(randomNumber, random);
}
return password;
}
private static void setSymbolsCount(int[] symbolsCountArray, int passwordLength)
{
symbolsCountArray[0] = passwordLength / 6;
symbolsCountArray[1] = passwordLength / 3;
symbolsCountArray[2] = (passwordLength - Arrays.stream(symbolsCountArray, 0, 2).sum()) / 2;
symbolsCountArray[3] = passwordLength - Arrays.stream(symbolsCountArray, 0, 3).sum();
}
private static char generateChar(int indexOfType, Random random)
{
return symbolsByIndexOfType[indexOfType].charAt(random.nextInt(symbolsByIndexOfType[indexOfType].length()));
}
}
35. By Michel Paeßens
Made by Michel Paeßens. The java program generates random passwords of random length. ( Source )
import java.util.Random;
import java.util.Scanner;
public class PasGeneration
{
private static String characters = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890";
private static Random rand = new Random();
private static int length = rand.nextInt(characters.length());
private static char[] text = new char[length];
private static String pas = "";
public static void main(String[] args) {
for(int i = 0; i < length; i++){
text[i] = characters.charAt(rand.nextInt(characters.length()));
}
for(int i = 0; i < text.length; i++){
pas += text[i];
}
System.out.println("Your Password: " + pas);
}
}
36. By Maxim Ageev
Made by Maxim Ageev. Enter password length you want to generate. ( Source )
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
ArrayList <Character> symbols = new ArrayList <Character> ();
symbols.add('a');
symbols.add('b');
symbols.add('c');
symbols.add('d');
symbols.add('e');
symbols.add('f');
symbols.add('g');
symbols.add('h');
symbols.add('i');
symbols.add('j');
symbols.add('k');
symbols.add('l');
symbols.add('m');
symbols.add('n');
symbols.add('o');
symbols.add('p');
symbols.add('q');
symbols.add('r');
symbols.add('s');
symbols.add('t');
symbols.add('u');
symbols.add('v');
symbols.add('w');
symbols.add('x');
symbols.add('y');
symbols.add('z');
symbols.add('A');
symbols.add('B');
symbols.add('C');
symbols.add('D');
symbols.add('E');
symbols.add('F');
symbols.add('G');
symbols.add('H');
symbols.add('I');
symbols.add('J');
symbols.add('K');
symbols.add('L');
symbols.add('M');
symbols.add('N');
symbols.add('O');
symbols.add('P');
symbols.add('Q');
symbols.add('R');
symbols.add('S');
symbols.add('T');
symbols.add('U');
symbols.add('V');
symbols.add('W');
symbols.add('X');
symbols.add('Y');
symbols.add('Z');
symbols.add('1');
symbols.add('2');
symbols.add('3');
symbols.add('4');
symbols.add('5');
symbols.add('6');
symbols.add('7');
symbols.add('8');
symbols.add('9');
symbols.add('0');
symbols.add('#');
symbols.add('_');
symbols.add('-');
symbols.add('?');
symbols.add('@');
symbols.add('=');
symbols.add('+');
symbols.add('!');
symbols.add(':');
symbols.add('%');
symbols.add('/');
symbols.add('*');
symbols.add('&');
symbols.add('.');
symbols.add(',');
symbols.add(')');
symbols.add('(');
symbols.add('"');
symbols.add(']');
symbols.add('[');
symbols.add('}');
symbols.add('{');
symbols.add('<');
symbols.add('>');
symbols.add('`');
symbols.add(';');
symbols.add('|');
symbols.add('^');
symbols.add('~');
symbols.add('$');
Collections.shuffle(symbols);
Scanner a = new Scanner(System.in);
int x = a.nextInt();
int k = 0;
while (k<x){
System.out.print(symbols.get(k));
k++;
}
}
}
37. By Makar Mikhalchenko
Made by Makar Mikhalchenko. Enter password length you want generate. The program also displays your password strength and its MD5 Hash. ( Source )
//Developed By Makar Mikhalchenko
/*Importing the
NoSuchAlgorithmException class.*/
import java.security.NoSuchAlgorithmException;
//Import the Date class.
import java.util.Date;
//Import the date editing class.
import java.text.SimpleDateFormat;
//Importing the MessageDigest class.
import java.security.MessageDigest;
//Importing the Random class.
import java.util.Random;
//Importing the Scanner class.
import java.util.Scanner;
//Denoting the name of the program class
public class GenPswd {
//We denote the main method.
public static void main(String[] args)
throws Exception {
/*With the help
currentTimeMillis, we
write time into a
variable startTime.*/
long startTime
= System.currentTimeMillis();
/*Creating an instance of the Scanner
class.*/
Scanner input = new Scanner(System.in);
/*Denoting an integer variable,
and assigning it user input.*/
int lengh = input.nextInt();
/*Disabling the Scanner
object so that it doesn't
consume the machine's resources.*/
input.close();
//Creating a lowercase letter variable.
String charsNorml =
"qwertyuiopasdfghjklzxcvbnm";
/*Creating a variable of uppercase
letters.*/
String charsUppercase =
"QWERTYUIOPASDFGHJKLZXCVBNM";
/*Creating a variable consisting of
numbers.*/
String numbers =
"1234567890";
/*🔰The value of special characters
is optional. Greatly increases
password protection. Not all
forms are supported.🔰*/
String specChars = "";
/*Creating a string consisting
of all our characters.*/
String pswd = charsNorml
+ charsUppercase + numbers + specChars;
/*We create a variable to
check the password for protection.*/
String protection = "";
/*Denoting an instance
of the Random class.*/
Random rnd = new Random();
/*Creating a Char array,
and setting the number
of elements equal to the
password length.*/
char[] pass = new char[lengh];
/*Creating a "for" loop
to execute body as many
times as the password length*/
for ( int i = 0; i < lengh; i++) {
/*When sorting an array into
elements, we assign a random
character to each element of
the "pass" array. Using
charAt(index); we select
a character from a string.
And the index of an individual
character is calculated by
Random (range);. We set
the range value by
specifying the length of
the string of all our
characters. Thus, at
each iteration of the
loop, we take a random
character from our
"pswd" string and
assign it to an array
element.*/
pass[i] =
pswd.charAt(rnd.nextInt
(pswd.length()));
};
/*We find out how long
the password is good.*/
if ( lengh <= 6) {
protection =
"🔓Password is too short.";
}
if (lengh > 6) {
protection =
"🔒Password is medium in length.";
}
if (lengh > 12) {
protection =
"🔐Password is high in length.";
}
//Output a message to the user.
System.out.print("🔰Your password: ");
//Output the value of the pass array.
System.out.println(pass);
System.out.println(protection);
/*Creating a string from
the char array*/
String passhex = new String(pass);
/*Creating the MessageDigest
object using the
getInstance ("SHA-1 or
SHA-256 or MD5"); method.*/
MessageDigest md =
MessageDigest.getInstance("MD5");
/*This method takes an
array of bytes representing
the message and
adds / passes it to the
MessageDigest object created
above.*/
md.update(passhex.getBytes());
/*This method calculates
the hash function for the
current object and returns
the message digest as a
byte array.*/
byte[] digest = md.digest();
/*Converting the byte
array in to HexString format*/
StringBuffer hexString = new
StringBuffer();
for (int i = 0;i<digest.length;i++) {
//Zeroing the high-level bits
hexString.append(Integer.toHexString
(0xFF & digest[i]));
}
/*Output the MD5 hash to the user*/
System.out.println
("🔰MD5 Hash: " +
hexString.toString());
//callback
System.out.println
("🔰Write a comment if you liked it!");
//Create an instance of the class
SimpleDateFormat dateFormat
= new SimpleDateFormat
("d MMM yyyy HH:mm:ss z");
//smiley of time
System.out.print("🔰");
//Print date
System.out.println
(dateFormat.format
(new Date() ) );
/*We write the end
time of the program
to a variable endTime.*/
long endTime
= System.currentTimeMillis();
//find the difference
long time = (endTime - startTime);
//smiley of time programm
System.out.print("🔰");
//Print the program run time
System.out.println
("Program runtime: " + (float)
time/1000 + " seconds");
}
}
38. By Sanskar Dhingra
Made by Sanskar Dhingra. Enter password length between 8 – 32. ( Source )
import java.util.*;
public class Pass {
static int n;
static Scanner x=new Scanner(System.in);
public static void main(String[] args) {
read();
if(n<8||n>32)
{System.out.println("Enter between 8 and 32 only"); main(args);}
else
generate();
}
static void read()
{
System.out.println("Enter password length");
n=x.nextInt();
}
static void generate()
{
String password="";
for(int i=1;i<=n;i++)
{
int a=(int)(Math.random()*127);
if(a<=32){i--;continue;}
password+=(char)a;
}
System.out.println("Password is : "+password);
}
}
39. By Renzo_Nogueira
Java password generator by Renzo_Nogueira. The program generates 4 random passwords that are 8 digits in length. ( Source )
//Author: Renzo Nogueira
import java.util.Random;
class Senha{
String [] symbols = {
"A","B","C","D","E","F",
"G","H","I","J","K","L","M",
"N","O","P","Q","R","S","T",
"U","V","W","X","Y","Z",
"a","b","c","d","e","f",
"g","h","i","j","k","l","m",
"n","o","p","q","r","s","t",
"u","v","w","x","y","z",
"0","1","2","3","4","5","6","7","8","9",
"&","%","@","&","!","?","=","^","+","~",
"-","$","#","*"
};
}
public class Program{
public static void main(String[]args){
int t=7;
int pos,i,j;
Random r = new Random();
Senha s = new Senha();
System.out.println("Password Tips:");
pos = r.nextInt(s.symbols.length);
for(i=0;i<=3;i++){
System.out.print("Password:\t\t");
for(j=0;j<=t;j++){
System.out.print(s.symbols[pos]);
pos = r.nextInt(s.symbols.length);
}
System.out.println();
}
}
}
40. By Simon Then
Made by Simon Then. Enter password length you want to generate for a random password. ( Source )
import java.util.Random;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
charsar c = new charsar();
c.start();
Scanner sc = new Scanner(System.in);
String password = "";
int pwdlength = sc.nextInt();
Random rnd = new Random();
int rndint;
for(int i = 0; i <= pwdlength;i++)
{
rndint = rnd.nextInt(61);
password += c.retchar(rndint);
}
System.out.println(password);
}
}
public class charsar {
public String[] d = new String[62];
public String retchar(int kc)
{
return d[kc];
}
public void start()
{
d[0] = "A";
d[1] = "B";
d[2] = "C";
d[3] = "D";
d[4] = "E";
d[5] = "F";
d[6] = "G";
d[7] = "H";
d[8] = "I";
d[9] = "J";
d[10] = "K";
d[11] = "L";
d[12] = "M";
d[13] = "N";
d[14] = "O";
d[15] = "P";
d[16] = "Q";
d[17] = "R";
d[18] = "S";
d[19] = "T";
d[20] = "U";
d[21] = "V";
d[22] = "W";
d[23] = "X";
d[24] = "Y";
d[25] = "Z";
d[26] = "@";
d[27] = "0";
d[28] = "1";
d[29] = "2";
d[30] = "3";
d[31] = "4";
d[32] = "5";
d[33] = "6";
d[34] = "7";
d[35] = "8";
d[36] = "9";
d[37] = "/";
d[38] = "[";
d[39] = "]";
d[40] = "?";
d[41] = "|";
d[42] = "<";
d[43] = ">";
d[44] = "(";
d[45] = ")";
d[46] = "+";
d[47] = "*";
d[48] = "-";
d[49] = "#";
d[50] = "'";
d[51] = "´";
d[52] = "§";
d[53] = "$";
d[54] = "%";
d[55] = "&";
d[56] = "=";
d[57] = ":";
d[58] = ",";
d[59] = ".";
d[60] = "_";
d[61] = "²";
}
}
41. By Akipid Ladnam
Made by Akipid Ladnam. Enter password length that is above 3 digits in length. ( Source )
import java.io.*;
public class Program
{
public static void main(String[] args)throws IOException {
String s="[email protected]#$%^&*(?~|₹_-+×÷=:;/{[<>]}";
int x,l=s.length();
BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter password length. It shall be greater than 3");
int length=Integer.parseInt(br.readLine());
if(length >3){
System.out.println("Your password is:");
while(length>0){
x=(int) (((double) l)*Math.random());
System.out.print(s.charAt(x));
length--;
}
System.out.println("");
}
else{
System.out.println("password length too small");
}
}
}
42. By Sparkling Hero
Made by Sparkling Hero. Enter password length for a random password, no limit to password length. ( Source )
import java.util.Random;
import java.util.Scanner;
public class program
{
public static void main(String[] args) {
Scanner sc1 = new Scanner(System.in);
System.out.println("Enter the number of chracters for the password :");
int num = sc1.nextInt();
String pas = program.generate(num);
System.out.println("The generated password is : "+pas);
}
public static String generate(int n) {
int i;
String small_characters = "abcdefghijklmnopqrstuvwxyz";
String big_characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String numbers = "1234567890";
String total = small_characters+big_characters+numbers;
Random selector = new Random();
char[] pass = new char[n];
for(i=0;i<n;i++)
{
pass[i] = total.charAt(selector.nextInt(total.length()));
}
StringBuilder sb1 = new StringBuilder();
sb1.append(pass);
return sb1.toString();
}
}
43. By Trevor Netshisaulu
Made by Trevor Netshisaulu. Enter your name to generate a random 8 digit password. ( Source )
import java.util.*;
public class PasswordGenerator {
public String myMethod(String greating) {
Scanner name = new Scanner(System.in);
String name1 = name.nextLine();
System.out.println(name1);
return greating;
}
public char[] outPutMethod(int leng) {
String symbols;
String strCap;
String strSml;
String numbers;
String outPut;
numbers = "0123456789";
strSml = "abcdefghijklmnopqrstuvwxyz";
strCap = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
symbols = "@#$+_-&<>~£€=[]%*()";
outPut = numbers + strSml + strCap + symbols;
Random rnd = new Random();
char[] charcter = new char[leng];
int index = 0;
for(int i =0; i < leng; i++) {
charcter[i] = outPut.charAt(rnd.nextInt(outPut.length()));
}
return charcter;
}
}
class SecondClass {
public static void main(String[] args) {
int length = 8;
PasswordGenerator psg = new PasswordGenerator();
System.out.print(psg.myMethod("Your password is: "));
System.out.println(psg.outPutMethod(length));
}
}
44. By Samantha
Java password generator by Samantha. The program generates a random 13 digit long password. ( Source )
import java.util.Random;
class Password{
public static void main(String[]args){
Random rand=new Random();
String[] password={"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","g","h","i","k","j","l","m","n","o","p","q","r","s","t","u","v","z","x","y","w"};
//String[] numeri={"0","1","2","3","4","5","6","7","8","9"};
System.out.println("");
System.out.println("Your password is:");
System.out.println("");
for(int i=1; i<=13; i++){
int b=(int)(Math.random()*36);
System.out.print(password[b]);
}System.out.println("");
}
}