Skip to content

Instantly share code, notes, and snippets.

@gotoark
Created February 6, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotoark/2cba204d8770278944ad92ee264dc315 to your computer and use it in GitHub Desktop.
Save gotoark/2cba204d8770278944ad92ee264dc315 to your computer and use it in GitHub Desktop.
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