Last active
December 28, 2015 00:29
-
-
Save giraam/7413470 to your computer and use it in GitHub Desktop.
Generate random seed specifying length in bytes unit
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
import java.util.Random; | |
import javax.xml.bind.DatatypeConverter; | |
/** | |
* Generate random seed | |
* | |
* @param seedlength Seed length in bytes unit | |
* @return seed | |
*/ | |
public String generateSeed(int seedlength) { | |
Random random = new Random(); | |
byte[] seed = new byte[seedlength]; | |
random.nextBytes(seed); | |
String strSeed; | |
strSeed = DatatypeConverter.printHexBinary(seed); | |
return strSeed; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment