Created
July 7, 2016 04:15
-
-
Save kakopappa/6cb930b5053ccd3a58cdca80c4cd8258 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static final String allChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
public static final String letterChar = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
public static final String numberChar = "0123456789"; | |
public static String generateString(int length) | |
{ | |
StringBuffer sb = new StringBuffer(); | |
SecureRandom random = new SecureRandom(); | |
for (int i = 0; i < length; i++) | |
{ | |
sb.append(allChar.charAt(random.nextInt(allChar.length()))); | |
} | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment