today im going to share with you a simple Java Class which is being able to generate passwords and their phonetics.
I hope that you are going to enjoy it
import java.util.HashMap; import com.google.gwt.user.client.Random; public class PasswordGenerator { protected static char[] goodChar = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9',}; static HashMap<String, String> nato = new HashMap<String, String>(); static{ nato.put("a", "alfa"); nato.put("b","bravo"); nato.put("c","charlie"); nato.put("d","delta"); nato.put("e","echo"); nato.put("f","foxtrot"); nato.put("g","golf"); nato.put("h","hotel"); nato.put("i","india"); nato.put("j","juliett"); nato.put("k","kilo"); nato.put("l","lima"); nato.put("m","mike"); nato.put("n","november"); nato.put("o","oscar"); nato.put("p","papa"); nato.put("q","quebec"); nato.put("r","romeo"); nato.put("s","sierra"); nato.put("t","tango"); nato.put("u","uniform"); nato.put("v","victor"); nato.put("w","whisky"); nato.put("x","x-ray"); nato.put("y","yankee"); nato.put("z","zulu"); nato.put("0","Zero"); nato.put("1","One"); nato.put("2","Two"); nato.put("3","Three"); nato.put("4","Four"); nato.put("5","Five"); nato.put("6","Six"); nato.put("7","Seven"); nato.put("8","Eight"); nato.put("9","Niner"); } public static String getNext(Integer length) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { sb.append(goodChar[Random.nextInt(goodChar.length)]); } return sb.toString(); } public static String getNatoPhonetic(String s){ String result = ""; for(int i = 0; i < s.length(); i++){ Character c = s.charAt(i); String x = nato.get(c.toString()); if(Character.isUpperCase(c) == true){ x = nato.get(c.toString().toLowerCase()); x = x.toUpperCase(); } if(result.equals("")==false) result += " - "; result += x; } return result; } /** *@param argv */ public static void main(String[] argv) { for (int i = 0; i < 20; i++) { System.out.println(PasswordGenerator.getNext(8)); System.out.println(PasswordGenerator.getNatoPhonetic("hWE58llo")); } } }