Class SecretKeyGenerator

java.lang.Object
org.cryptacular.generator.SecretKeyGenerator

public final class SecretKeyGenerator extends Object
Factory class with static methods for generating SecretKeys.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final int
    Maximum length of secret keys in bits to generate in bits.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Private constructor of static class.
  • Method Summary

    Modifier and Type
    Method
    Description
    static SecretKey
    generate(int bitLength, org.bouncycastle.crypto.BlockCipher cipher)
    Generates a symmetric encryption key of the given length.
    static SecretKey
    generate(int bitLength, org.bouncycastle.crypto.BlockCipher cipher, SecureRandom random)
    Generates a symmetric encryption key of the given length.
    static SecretKey
    generate(org.bouncycastle.crypto.BlockCipher cipher)
    Generates a symmetric encryption key whose size is equal to the cipher block size.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_KEY_LENGTH

      private static final int MAX_KEY_LENGTH
      Maximum length of secret keys in bits to generate in bits.
  • Constructor Details

    • SecretKeyGenerator

      private SecretKeyGenerator()
      Private constructor of static class.
  • Method Details

    • generate

      public static SecretKey generate(org.bouncycastle.crypto.BlockCipher cipher)
      Generates a symmetric encryption key whose size is equal to the cipher block size.
      Parameters:
      cipher - Cipher with key will be used.
      Returns:
      Symmetric encryption key.
    • generate

      public static SecretKey generate(int bitLength, org.bouncycastle.crypto.BlockCipher cipher)
      Generates a symmetric encryption key of the given length.
      Parameters:
      bitLength - Desired key length in bits.
      cipher - Cipher with key will be used.
      Returns:
      Symmetric encryption key.
    • generate

      public static SecretKey generate(int bitLength, org.bouncycastle.crypto.BlockCipher cipher, SecureRandom random)
      Generates a symmetric encryption key of the given length.
      Parameters:
      bitLength - Desired key length in bits.
      cipher - Cipher with key will be used.
      random - Randomness provider for key generation.
      Returns:
      Symmetric encryption key.