Created
October 18, 2012 20:10
-
-
Save cbmeeks/3914488 to your computer and use it in GitHub Desktop.
Random String in Java
This file contains hidden or 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
/* ************************************************************************ | |
* 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