生成安全随机数
import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; public class Main {/** 来 自 nowjava.com**/ public void myMethod() { try { // Create a secure random number generator SecureRandom sr = SecureRandom.getInstance("SHA1PRNG"); // Get 1024 random bits byte[] bytes = new byte[1024 / 8]; sr.nextBytes(bytes); // Create two secure number generators with the same seed int seedByteCount = 10; byte[] seed = sr.generateSeed(seedByteCount);/**来自 nowjava - 时代Java**/ sr = SecureRandom.getInstance("SHA1PRNG"); sr.setSeed(seed);