Java tutorial
//package com.java2s; import java.security.SecureRandom; public class Main { private static final String RANDOM_ALGORITHM = "SHA1PRNG"; private static byte[] randomBytes(int length) throws Exception { SecureRandom random = SecureRandom.getInstance(RANDOM_ALGORITHM); byte[] b = new byte[length]; random.nextBytes(b); return b; } }