Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Purpose: Randomly Generate Good passwords
- * Date: November 26, 2009
- * Author: Serraphyn
- */
- import java.util.Random;
- class PasswordGenerator {
- public static void main(int aLength) {
- char aLetter; // CHAR type variable to hold our single letters
- String aPassword = ""; // String type to hold the entire password as it is being built
- int aNumber; // int type variable to hold our sing numbers from 0 - 9
- String aSymbol = ""; // String type variable to pass various SHIFT+ ! - _
- // Start a For Loop to begin password creation
- for (int x=0; x <= aLength; ++x) {
- aLetter = RandomLetter('c');// Call a single Letter
- aNumber = RandomInteger(9); // Call a sing Integer
- aPassword = Character.toString(aLetter) + Integer.toString(aNumber);
- }
- log(aPassword); // Display output
- }
- private static int RandomInteger(int args) {
- Random RG = new Random();
- int RGI = RG.nextInt(args);
- return RGI;
- }
- private static char RandomSymbol(char args) {
- Random RC = new Random();
- char[] chars = new char[]{'!','@','#','$','%','^','&','*','(',')','_','-'};
- int r = RC.nextInt(chars.length);
- char rndchar = chars[r];
- return rndchar;
- }
- private static char RandomLetter(char args) {
- Random RG = new Random();
- //char chars = (char)(RG.nextInt(Character.MAX_VALUE + 1));
- Random R = new Random();
- int i = R.nextInt(2);
- char chars;
- if (i <= 0) {
- chars = (char)((int)'a'+Math.random()*((int)'z'-(int)'a'+1));
- } else {
- chars = (char)((int)'A'+Math.random()*((int)'Z'-(int)'A'+1));
- }
- return chars;
- }
- private static String RandomWord(String args) {
- return args;
- }
- private static String LetterToNumber(String aWord) {
- return aWord.replace('O', '0');
- }
- private static void log(String aMsg) {
- System.out.println(aMsg);
- }
- }
Add Comment
Please, Sign In to add comment