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

org.solovyev.common.security.SecurityUtils Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
package org.solovyev.common.security;

import org.jetbrains.annotations.NotNull;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.Random;

/**
 * User: serso
 * Date: 8/20/12
 * Time: 8:14 PM
 */
public final class SecurityUtils {

    private SecurityUtils() {
        throw new AssertionError();
    }

    public static byte[] generateRandomBytes(@NotNull String randomAlgorithm, int length) throws NoSuchAlgorithmException, NoSuchProviderException {
        final Random random = SecureRandom.getInstance(randomAlgorithm);
        byte[] result = new byte[length];
        random.nextBytes(result);
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy