Skip to content

Instantly share code, notes, and snippets.

@giraam
Last active December 28, 2015 00:29
Show Gist options
  • Save giraam/7413470 to your computer and use it in GitHub Desktop.
Save giraam/7413470 to your computer and use it in GitHub Desktop.
Generate random seed specifying length in bytes unit
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