Created
February 6, 2018 11:55
-
-
Save gotoark/2cba204d8770278944ad92ee264dc315 to your computer and use it in GitHub Desktop.
Generate Random String https://stackoverflow.com/a/157202/5740760
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
static final String AB = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | |
static SecureRandom rnd = new SecureRandom(); | |
public static String randomString( int len ){ | |
StringBuilder sb = new StringBuilder( len ); | |
for( int i = 0; i < len; i++ ) | |
sb.append( AB.charAt( rnd.nextInt(AB.length()) ) ); | |
return sb.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment