0

how can i make a Password Generator?

i had this idea (it doesn't seem to work well)... its not that random, its just bad... how can make it good or just give me an idea for a good way... code: import java.util.*; public class Main { public static void main(String[] args){ //Password Generator: char[] noCap = {'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'}; char[] withCap = {'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'}; int[] numbers = {1, 2, 3, 4, 5, 6, 7, 8, 9}; Random r = new Random(); char randomNoCap = noCap[r.nextInt(26)]; char randomWithCap = withCap[r.nextInt(26)]; int randomNumber = numbers[r.nextInt(9)]; System.out.print(randomNumber); System.out.print(randomWithCap); System.out.print(randomNoCap); } }

3rd Jul 2020, 11:02 AM
Yahel
Yahel - avatar
1 Answer
0
How can I do that I pick 3 chars from each array? I tried to write * 3 , and then it converts it into a big number
3rd Jul 2020, 12:41 PM
Yahel
Yahel - avatar