Key factories are used to convert keys (opaque
cryptographic keys of type Key
) into key specifications
(transparent representations of the underlying key material), and vice
versa.
Secret key factories operate only on secret (symmetric) keys.
Key factories are bi-directional, i.e., they allow to build an opaque key object from a given key specification (key material), or to retrieve the underlying key material of a key object in a suitable format.
Application developers should refer to their provider's documentation
to find out which key specifications are supported by the
generateSecret
and
getKeySpec
methods.
For example, the DESede (Triple DES) secret-key factory supplied by the
"SunJCE" provider supports DESedeKeySpec
as a transparent
representation of Triple DES keys.
Every implementation of the Java platform is required to support the
following standard SecretKeyFactory
algorithms:
DESede
- Since:
- 1.4
- See Also:
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
SecretKeyFactory
(SecretKeyFactorySpi keyFacSpi, Provider provider, String algorithm) Creates a SecretKeyFactory object. -
Method Summary
Modifier and TypeMethodDescriptionfinal SecretKey
generateSecret
(KeySpec keySpec) Generates aSecretKey
object from the provided key specification (key material).final String
Returns the algorithm name of thisSecretKeyFactory
object.static final SecretKeyFactory
getInstance
(String algorithm) Returns aSecretKeyFactory
object that converts secret keys of the specified algorithm.static final SecretKeyFactory
getInstance
(String algorithm, String provider) Returns aSecretKeyFactory
object that converts secret keys of the specified algorithm.static final SecretKeyFactory
getInstance
(String algorithm, Provider provider) Returns aSecretKeyFactory
object that converts secret keys of the specified algorithm.final KeySpec
getKeySpec
(SecretKey key, Class<?> keySpec) Returns a specification (key material) of the given key object in the requested format.final