This could have probably been done in a similar way, but, I got it done none the less.
EDIT: I made it so you can save this to a file. I probably could have made it so you didn't have to paste your password, but I think I may have rewrite a lot of stuff, and I'm very lazy
.
If anyone knows how to generate a random object out of a string
I.E:
String n = ['a','b','c']
then print a random object out of there
feel free to post it
Code:
import java.util.*;
import java.lang.*;
class pass
{
public static void main(String[] args)
{
Scanner len = new Scanner(System.in);
System.out.print("How many digits should be in your password?: ");
int ilen = len.nextInt();
while (0 < ilen)
{
Random number = new Random();
int inumber = number.nextInt(34);
ilen = ilen - 1;
if (inumber == 1)
System.out.print("a");
else if (inumber == 2)
System.out.print("b");
else if (inumber == 3)
System.out.print("c");
else if (inumber == 4)
System.out.print("d");
else if (inumber == 5)
System.out.print("e");
else if (inumber == 6)
System.out.print("f");
else if (inumber == 7)
System.out.print("g");
else if (inumber == 8)
System.out.print("h");
else if (inumber == 9)
System.out.print("i");
else if (inumber == 10)
System.out.print("j");
else if (inumber == 11)
System.out.print("k");
else if (inumber == 12)
System.out.print("l");
else if (inumber == 13)
System.out.print("m");
else if (inumber == 14)
System.out.print("n");
else if (inumber == 15)
System.out.print("o");
else if (inumber == 16)
System.out.print("p");
else if (inumber == 17)
System.out.print("q");
else if (inumber == 18)
System.out.print("r");
else if (inumber == 19)
System.out.print("s");
else if (inumber == 20)
System.out.print("t");
else if (inumber == 21)
System.out.print("u");
else if (inumber == 22)
System.out.print("w");
else if (inumber == 23)
System.out.print("x");
else if (inumber == 24)
System.out.print("y");
else if (inumber == 25)
System.out.print("z");
else if (inumber == 26)
System.out.print("1");
else if (inumber == 27)
System.out.print("2");
else if (inumber == 28)
System.out.print("3");
else if (inumber == 29)
System.out.print("4");
else if (inumber == 30)
System.out.print("5");
else if (inumber == 31)
System.out.print("6");
else if (inumber == 32)
System.out.print("7");
else if (inumber == 33)
System.out.print("8");
else if (inumber == 34)
System.out.print("9");
}
System.out.println("");
}
}
EDIT: I made it so you can save this to a file. I probably could have made it so you didn't have to paste your password, but I think I may have rewrite a lot of stuff, and I'm very lazy
![Big Grin Big Grin](https://www.supportforums.net/images/smilies/biggrin.gif)
Code:
import java.util.*;
import java.lang.*;
import java.io.*;
class pass
{
public static void main(String[] args)throws IOException
{
Scanner len = new Scanner(System.in);
System.out.print("How many digits should be in your password?: ");
int ilen = len.nextInt();
while (0 < ilen)
{
Random number = new Random();
int inumber = number.nextInt(34);
ilen = ilen - 1;
if (inumber == 1)
System.out.print("a");
else if (inumber == 2)
System.out.print("b");
else if (inumber == 3)
System.out.print("c");
else if (inumber == 4)
System.out.print("d");
else if (inumber == 5)
System.out.print("e");
else if (inumber == 6)
System.out.print("f");
else if (inumber == 7)
System.out.print("g");
else if (inumber == 8)
System.out.print("h");
else if (inumber == 9)
System.out.print("i");
else if (inumber == 10)
System.out.print("j");
else if (inumber == 11)
System.out.print("k");
else if (inumber == 12)
System.out.print("l");
else if (inumber == 13)
System.out.print("m");
else if (inumber == 14)
System.out.print("n");
else if (inumber == 15)
System.out.print("o");
else if (inumber == 16)
System.out.print("p");
else if (inumber == 17)
System.out.print("q");
else if (inumber == 18)
System.out.print("r");
else if (inumber == 19)
System.out.print("s");
else if (inumber == 20)
System.out.print("t");
else if (inumber == 21)
System.out.print("u");
else if (inumber == 22)
System.out.print("w");
else if (inumber == 23)
System.out.print("x");
else if (inumber == 24)
System.out.print("y");
else if (inumber == 25)
System.out.print("z");
else if (inumber == 26)
System.out.print("1");
else if (inumber == 27)
System.out.print("2");
else if (inumber == 28)
System.out.print("3");
else if (inumber == 29)
System.out.print("4");
else if (inumber == 30)
System.out.print("5");
else if (inumber == 31)
System.out.print("6");
else if (inumber == 32)
System.out.print("7");
else if (inumber == 33)
System.out.print("8");
else if (inumber == 34)
System.out.print("9");
}
System.out.println("");
Scanner syesno = new Scanner(System.in);
int iyesno;
System.out.println("1) Yes");
System.out.println("2) No");
System.out.print("Do you want to save this?: ");
iyesno = syesno.nextInt();
if (iyesno == 1)
{
Scanner swhatfor = new Scanner(System.in);
String Stringwhatfor;
Scanner spassw = new Scanner(System.in);
String Stringpassw;
System.out.print("What is this for?: ");
Stringwhatfor = swhatfor.next();
System.out.print("Please paste the password here: ");
Stringpassw = spassw.next();
Writer output = null;
File file = new File(Stringwhatfor);
output = new BufferedWriter(new FileWriter(file));
output.write(Stringpassw);
output.close();
System.out.println("Saved!");
}
else
{
}
}
}
If anyone knows how to generate a random object out of a string
I.E:
String n = ['a','b','c']
then print a random object out of there
feel free to post it
![Big Grin Big Grin](https://www.supportforums.net/images/smilies/biggrin.gif)