Skip to content

Instantly share code, notes, and snippets.

@cbmeeks
Created October 18, 2012 20:10
Show Gist options
  • Save cbmeeks/3914488 to your computer and use it in GitHub Desktop.
Save cbmeeks/3914488 to your computer and use it in GitHub Desktop.
Random String in Java
/* ************************************************************************
* Class: Random.java
* Purpose: Helper class for generating random strings (for new passwords)
* Author: Cecil Meeks
* Modification History:
* 2011 - Cecil Meeks - Creation
// ************************************************************************ */
package com.example.common;
import java.math.BigInteger;
import java.security.SecureRandom;
/**
*
* @author Cecil.Meeks
*/
public class Random {
public static String string() {
SecureRandom random = new SecureRandom();
return new BigInteger(130, random).toString(32);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment