List of utility methods to do Password Generate
String | generatePassword() generate Password try { char[] charArray = "abcdefghijklmnopqrstuvwxyz".toCharArray(); StringBuilder stringBuilder = new StringBuilder(); Random random = new Random(); for (int i = 0; i < 10; i++) { char c = charArray[random.nextInt(charArray.length)]; stringBuilder.append(c); String randomPassword = stringBuilder.toString(); return randomPassword; } catch (Exception e) { throw new Exception("Password generation failed!"); |
String | generatePassword() Generates a random password of 8 characters String password = ""; String values[] = { "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "m", "n", "p", "q", "r", "s", "t", "u", "v", "z", "x", "y", "1", "2", "3", "4", "5", "6", "7", "8", "9", "&", "%", "?", "!", "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "S", "T", "U", "V", "Z", "X", "Y" }; Random ran = new Random(); int range = values.length; int number; ... |
String | generatePassword() generate Password String password = ""; for (int i = 0; i < 30; i++) { Random rand = new Random(); password += random_str.charAt(rand.nextInt(random_str.length())); return password; |
String | generatePassword() Generate password from alpha numerics characters in total length 8 characters. final char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".toCharArray(); final StringBuilder sb = new StringBuilder(); final Random random = new Random(); for (int i = 0; i < PASSWORD_LENGT; i++) { final char c = chars[random.nextInt(chars.length)]; sb.append(c); return sb.toString(); ... |
String | generatePassword() generate Password StringBuilder builder = new StringBuilder(); for (int i = 0; i < 10; i++) { int r = Math.abs(random.nextInt()); builder.append((char) (33 + r % (126 - 33))); return builder.toString(); |
String | generatePassword() generate Password int[] array = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Random rand = new Random(); for (int i = 10; i > 1; i--) { int index = rand.nextInt(i); int tmp = array[index]; array[index] = array[i - 1]; array[i - 1] = tmp; int result = 0; for (int i = 0; i < 6; i++) result = result * 10 + array[i]; return String.valueOf(result); |
String | generatePassword(int lenght) generate Password StringBuffer sb = new StringBuffer(); for (int i = 0; i < lenght; i++) { sb.append(_goodChar[_random.nextInt(_goodChar.length)]); return sb.toString(); |
String | generatePassword(int length) generate Password if (length <= 0) { return ""; Random random = new Random(); StringBuilder sb = new StringBuilder(); String exCludeChar = "'<>&"; String[] charSets = { DIGITS, LETTERS, SPECIALS }; for (int i = 0; i < length; i++) { ... |
String | generatePassword(int length) Generates a random password with the specified length. StringBuffer pwd = new StringBuffer(); Random rnd = new Random(); for (int i = 0; i < length; i++) { pwd.append(pwdChars.charAt(rnd.nextInt(pwdChars.length()))); return pwd.toString(); |
String | generatePassword(int length, boolean special) Generates a random String of characters of the specified length. final char[] characters = new char[] { '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', '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', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '~', '`', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '-', '+', '=', '[', '{', '}', ']', '\\', '|', ';', ':', '\'', '"', '<', ',', '>', '.', '?', '/' }; String password = ""; for (int i = 0; i < length; i++) { password += characters[(new Random()).nextInt(special ? characters.length : 62)]; ... |