Definition
As there is nothing more frustrating than create a new random password for everyone in a company, the automated process to do so could be required somewhere.Summary
In the following script we create a java class "PassGen01" which has three main variables, containing two arrays of words and a random two digit number.Later we have another two number generator (0 to 3 as the possible positions of the two arrays we have)
Finally, everything is concatenated into the variable "pass" and shown into console through a System.out
Code
public class PassGen01 {public static void main(String[] args) {
String[] pass_list01 = {"Spring", "Summer", "Autumn", "Winter"};
String[] pass_list02 = {"Day", "Month", "Year", "Decade"};
int pass_num_random = ((int)(Math.random() * (99 - 10) + 10));
int pass_list_index_random01 = ((int)(Math.random() * (3 - 0)));
int pass_list_index_random02 = ((int)(Math.random() * (3 - 0)));
String pass = (pass_list01[pass_list_index_random01])
+ (pass_list02[pass_list_index_random02])
+ (pass_num_random)
+ "!";
System.out.println(pass);
}
}
Results
AutumnMonth25!SummerMonth95!
AutumnDay77!
AutumnYear65!
SpringYear94!
No hay comentarios:
Publicar un comentario