Advertisement
Guest User

Untitled

a guest
Nov 30th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. length = keyboard.nextInt();
  2. keyboard.nextLine();
  3.  
  4. System.out.println("Please type in yes or no for the following questions.");
  5. System.out.println("Would you like to include capital letters in your password? ");
  6. response=keyboard.nextLine().toLowerCase();
  7. if(response.equalsIgnoreCase("yes"))
  8. {list[0]=1;}
  9. if(response.equalsIgnoreCase("no"))
  10. {list[0]=0;}
  11.  
  12. System.out.println("Would you like to include lowercase letters in your password? ");
  13. response=keyboard.nextLine().toLowerCase();
  14. if(response.equalsIgnoreCase("yes"))
  15. {list[1]=1;}
  16. if(response.equalsIgnoreCase("no"))
  17. {list[1]=0;}
  18.  
  19. System.out.println("Would you like to include numbers in your password? ");
  20. response=keyboard.nextLine().toLowerCase();
  21. if(response.equalsIgnoreCase("yes"))
  22. {list[2]=1;}
  23. if(response.equalsIgnoreCase("no"))
  24. {list[2]=0;}
  25.  
  26. System.out.println("Would you like to include symbols letters in your password? ");
  27. response=keyboard.nextLine().toLowerCase();
  28. if(response.equalsIgnoreCase("yes"))
  29. {list[3]=1;}
  30. if(response.equalsIgnoreCase("no"))
  31. {list[3]=0;}
  32.  
  33. System.out.println(Arrays.toString(list));
  34.  
  35. System.out.println(length+"length of password");
  36. }////
  37.  
  38. SecureRandom character = new SecureRandom();
  39. String Capital="QWERTYUIOPASDFGHJKLZXCVBNM";
  40. String LowerCase="qwertyuiopasdfghjklzxcvbnm";
  41. String Numbers="1234567890";
  42. String Special="!@#$%&*?";
  43. String alphabet="";
  44. String Password;
  45. if(list[0]==1)
  46. alphabet= alphabet.concat(Capital);
  47. if(list[1]==1)
  48. alphabet=alphabet.concat(LowerCase);
  49. if(list[2]==1)
  50. alphabet=alphabet.concat(Numbers);
  51. if(list[3]==1)
  52. alphabet=alphabet.concat(Special);
  53. for(int i=0; i<length;i++)
  54.  
  55. System.out.println(alphabet.charAt(character.nextInt(alphabet.length())));
  56.  
  57.  
  58.  
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement