List of usage examples for org.bouncycastle.crypto.prng SP800SecureRandomBuilder SP800SecureRandomBuilder
public SP800SecureRandomBuilder()
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)); }