All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.codehaus.httpcache4j.util.SecureRandomFactory Maven / Gradle / Ivy

There is a newer version: 5.1.1
Show newest version
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