Example usage for org.bouncycastle.crypto.prng SP800SecureRandomBuilder SP800SecureRandomBuilder

List of usage examples for org.bouncycastle.crypto.prng SP800SecureRandomBuilder SP800SecureRandomBuilder

Introduction

In this page you can find the example usage for org.bouncycastle.crypto.prng SP800SecureRandomBuilder SP800SecureRandomBuilder.

Prototype

public SP800SecureRandomBuilder() 

Source Link

Document

Basic constructor, creates a builder using an EntropySourceProvider based on the default SecureRandom with predictionResistant set to false.

Usage

From source file:org.cryptacular.generator.SecretKeyGenerator.java

License:Open Source License

/**
 * Generates a symmetric encryption key of the given length.
 *
 * @param  bitLength  Desired key length in bits.
 * @param  cipher  Cipher with with key will be used.
 *
 * @return  Symmetric encryption key./*from ww  w . j a v  a 2s . co  m*/
 */
public static SecretKey generate(final int bitLength, final BlockCipher cipher) {
    // Want as much nonce data as key bits
    final byte[] nonce = NonceUtil.timestampNonce((bitLength + 7) / 8);
    return generate(bitLength, cipher,
            new SP800SecureRandomBuilder().buildHash(new SHA256Digest(), nonce, false));
}