java.lang.Object
org.seppiko.commons.utils.crypto.GeneratorUtil
Key and KeyPair Generator object util
And SecureRandom object util
- Author:
- Leonard Woo
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic AlgorithmParameterGeneratoralgorithmParameterGenerator(String algorithm) Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.static AlgorithmParameterGeneratoralgorithmParameterGenerator(String algorithm, Provider provider) Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.static KeyGeneratorkeyGenerator(String algorithm) Returns a KeyGenerator object that generates secret keys for the specified algorithm.static KeyGeneratorkeyGenerator(String algorithm, Provider provider) Returns a KeyGenerator object that generates secret keys for the specified algorithm.static SecretKeykeyGenerator(String algorithm, Provider provider, int keySize) Cryptographic key generatorstatic KeyPairGeneratorkeyPairGenerator(String algorithm) Returns a KeyPairGenerator object that generates public/private key pairs for the specified algorithm.static KeyPairGeneratorkeyPairGenerator(String algorithm, Provider provider) Returns a KeyPairGenerator object that generates public/private key pairs for the specified * algorithm.static KeyPairkeyPairGenerator(String algorithm, Provider provider, int keySize) Asymmetric cryptographic key pair generatorstatic KeyPairkeyPairGenerator(String algorithm, Provider provider, AlgorithmParameterSpec params) Asymmetric cryptographic key pair generatorstatic SecureRandomsecureRandom(String algorithm) Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.static SecureRandomsecureRandom(String algorithm, Provider provider) Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.static SecureRandomsecureRandom(String algorithm, Provider provider, SecureRandomParameters params) Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.
-
Constructor Details
-
GeneratorUtil
public GeneratorUtil()
-
-
Method Details
-
keyGenerator
public static KeyGenerator keyGenerator(String algorithm) throws NoSuchAlgorithmException, NullPointerException Returns a KeyGenerator object that generates secret keys for the specified algorithm.- Parameters:
algorithm- the standard name of the requested key algorithm- Returns:
- new KeyGenerator object
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyGeneratorSpi implementation for the specified algorithmNullPointerException- if algorithm is null
-
keyGenerator
public static KeyGenerator keyGenerator(String algorithm, Provider provider) throws NoSuchAlgorithmException, NullPointerException, IllegalArgumentException Returns a KeyGenerator object that generates secret keys for the specified algorithm.- Parameters:
algorithm- the standard name of the requested key algorithmprovider- the provider- Returns:
- new KeyGenerator object
- Throws:
NoSuchAlgorithmException- if a KeyGeneratorSpi implementation for the specified algorithm is not available from the specified Provider objectNullPointerException- if algorithm is nullIllegalArgumentException- if the provider is null
-
keyPairGenerator
public static KeyPairGenerator keyPairGenerator(String algorithm) throws NoSuchAlgorithmException, NullPointerException Returns a KeyPairGenerator object that generates public/private key pairs for the specified algorithm.- Parameters:
algorithm- the standard string name of the algorithm- Returns:
- the new KeyPairGenerator object
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyPairGeneratorSpi implementation for the specified algorithmNullPointerException- if algorithm is null
-
keyPairGenerator
public static KeyPairGenerator keyPairGenerator(String algorithm, Provider provider) throws NoSuchAlgorithmException, IllegalArgumentException, NullPointerException Returns a KeyPairGenerator object that generates public/private key pairs for the specified * algorithm.- Parameters:
algorithm- the standard string name of the algorithmprovider- the provider- Returns:
- the new KeyPairGenerator object
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyPairGeneratorSpi implementation for the specified algorithmIllegalArgumentException- if the specified provider is nullNullPointerException- if algorithm is null
-
algorithmParameterGenerator
public static AlgorithmParameterGenerator algorithmParameterGenerator(String algorithm) throws NoSuchAlgorithmException, NullPointerException Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.- Parameters:
algorithm- the name of the algorithm this parameter generator is associated with- Returns:
- the new AlgorithmParameterGenerator object
- Throws:
NoSuchAlgorithmException- if an AlgorithmParameterGeneratorSpi implementation for the specified algorithm is not available from the specified Provider objectNullPointerException- if algorithm is null
-
algorithmParameterGenerator
public static AlgorithmParameterGenerator algorithmParameterGenerator(String algorithm, Provider provider) throws NoSuchAlgorithmException, IllegalArgumentException, NullPointerException Returns an AlgorithmParameterGenerator object for generating a set of parameters to be used with the specified algorithm.- Parameters:
algorithm- the name of the algorithm this parameter generator is associated withprovider- the Provider- Returns:
- the new AlgorithmParameterGenerator object
- Throws:
NoSuchAlgorithmException- if an AlgorithmParameterGeneratorSpi implementation for the specified algorithm is not available from the specified Provider objectIllegalArgumentException- if the specified provider is nullNullPointerException- if algorithm is null
-
keyGenerator
public static SecretKey keyGenerator(String algorithm, Provider provider, int keySize) throws NoSuchAlgorithmException, NullPointerException, IllegalArgumentException Cryptographic key generator- Parameters:
algorithm- the standard name of the requested key algorithmprovider- the provider, if use default provider is nullkeySize- key size- Returns:
- secret key byte array
- Throws:
NoSuchAlgorithmException- if a KeyGeneratorSpi implementation for the specified algorithm is not available from the specified Provider objectNullPointerException- if algorithm is nullIllegalArgumentException- if the provider is null
-
keyPairGenerator
public static KeyPair keyPairGenerator(String algorithm, Provider provider, int keySize) throws NoSuchAlgorithmException, IllegalArgumentException, NullPointerException Asymmetric cryptographic key pair generator- Parameters:
algorithm- the standard string name of the algorithmprovider- the provider, if use default provider is nullkeySize- key size- Returns:
- key pair object
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyPairGeneratorSpi implementation for the specified algorithm.IllegalArgumentException- if the provider is null.NullPointerException- if algorithm is null.- See Also:
-
keyPairGenerator
public static KeyPair keyPairGenerator(String algorithm, Provider provider, AlgorithmParameterSpec params) throws NoSuchAlgorithmException, IllegalArgumentException, NullPointerException, InvalidAlgorithmParameterException Asymmetric cryptographic key pair generator- Parameters:
algorithm- the standard string name of the algorithmprovider- the provider, if use default provider is nullparams- the parameter set used to generate the keys- Returns:
- key pair object
- Throws:
NoSuchAlgorithmException- if no Provider supports a KeyPairGeneratorSpi implementation for the specified algorithm.IllegalArgumentException- if the provider is null.NullPointerException- if algorithm is null.InvalidAlgorithmParameterException- if the given parameters are inappropriate for this key pair generator.- See Also:
-
secureRandom
public static SecureRandom secureRandom(String algorithm) throws NoSuchAlgorithmException, NullPointerException Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.- Parameters:
algorithm- the name of the RNG algorithm- Returns:
- the new SecureRandom object
- Throws:
NoSuchAlgorithmException- if no Provider supports a SecureRandomSpi implementation for the specified algorithmNullPointerException- if algorithm is null
-
secureRandom
public static SecureRandom secureRandom(String algorithm, Provider provider) throws NoSuchAlgorithmException, NullPointerException Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.- Parameters:
algorithm- the name of the RNG algorithmprovider- the provider- Returns:
- the new SecureRandom object
- Throws:
NoSuchAlgorithmException- if no Provider supports a SecureRandomSpi implementation for the specified algorithmNullPointerException- if algorithm is null
-
secureRandom
public static SecureRandom secureRandom(String algorithm, Provider provider, SecureRandomParameters params) throws NoSuchAlgorithmException, NullPointerException, IllegalArgumentException Returns a SecureRandom object that implements the specified Random Number Generator (RNG) algorithm.- Parameters:
algorithm- the name of the RNG algorithmprovider- the providerparams- the SecureRandomParameters the newly created SecureRandom object must support- Returns:
- the new SecureRandom object
- Throws:
NoSuchAlgorithmException- if no Provider supports a SecureRandomSpi implementation for the specified algorithmNullPointerException- if algorithm is nullIllegalArgumentException- if the specified provider or params is null
-