org.codehaus.httpcache4j.util.SecureRandomFactory Maven / Gradle / Ivy
package org.codehaus.httpcache4j.util;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
/**
* @author Erlend Hamnaberg
*/
public class SecureRandomFactory {
public static SecureRandom getRandom() {
return getRandom(null);
}
public static SecureRandom getRandom(byte[] seed) {
try {
SecureRandom rnd = SecureRandom.getInstance("SHA1PRNG");
if (seed != null) {
rnd.setSeed(seed);
}
return rnd;
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy