Guest User

Untitled

a guest
Jul 18th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. /*
  2. * Purpose: Randomly Generate Good passwords
  3. * Date: November 26, 2009
  4. * Author: Serraphyn
  5. */
  6. import java.util.Random;
  7.  
  8.  
  9. class PasswordGenerator {
  10.  
  11. public static void main(int aLength) {
  12.  
  13. char aLetter; // CHAR type variable to hold our single letters
  14. String aPassword = ""; // String type to hold the entire password as it is being built
  15. int aNumber; // int type variable to hold our sing numbers from 0 - 9
  16. String aSymbol = ""; // String type variable to pass various SHIFT+ ! - _
  17.  
  18. // Start a For Loop to begin password creation
  19. for (int x=0; x <= aLength; ++x) {
  20.  
  21. aLetter = RandomLetter('c');// Call a single Letter
  22.  
  23. aNumber = RandomInteger(9); // Call a sing Integer
  24.  
  25. aPassword = Character.toString(aLetter) + Integer.toString(aNumber);
  26. }
  27. log(aPassword); // Display output
  28.  
  29.  
  30. }
  31.  
  32. private static int RandomInteger(int args) {
  33. Random RG = new Random();
  34. int RGI = RG.nextInt(args);
  35. return RGI;
  36. }
  37.  
  38. private static char RandomSymbol(char args) {
  39. Random RC = new Random();
  40. char[] chars = new char[]{'!','@','#','$','%','^','&','*','(',')','_','-'};
  41. int r = RC.nextInt(chars.length);
  42.  
  43. char rndchar = chars[r];
  44.  
  45. return rndchar;
  46.  
  47.  
  48. }
  49.  
  50. private static char RandomLetter(char args) {
  51.  
  52. Random RG = new Random();
  53. //char chars = (char)(RG.nextInt(Character.MAX_VALUE + 1));
  54.  
  55. Random R = new Random();
  56. int i = R.nextInt(2);
  57. char chars;
  58.  
  59. if (i <= 0) {
  60. chars = (char)((int)'a'+Math.random()*((int)'z'-(int)'a'+1));
  61. } else {
  62. chars = (char)((int)'A'+Math.random()*((int)'Z'-(int)'A'+1));
  63. }
  64.  
  65. return chars;
  66.  
  67.  
  68. }
  69.  
  70. private static String RandomWord(String args) {
  71. return args;
  72. }
  73.  
  74. private static String LetterToNumber(String aWord) {
  75. return aWord.replace('O', '0');
  76. }
  77.  
  78. private static void log(String aMsg) {
  79. System.out.println(aMsg);
  80. }
  81.  
  82. }
Add Comment
Please, Sign In to add comment