There is another way to generate keys, and that is through the use of key factories. Key factories are most often used to import and export keys; the factory translates between an external format of the key that is easily transportable and the internal implementation of the key. There are certain types of keys, however, that can only be obtained via a key factory since there is no key generator to produce them (e.g., a password-based encryption key).
There are two external representations by which a key may be
transmitted -- by its encoded format or by the parameters that
were used to generate the key. Either of these representations may be
encapsulated in a key specification, which is used to interact with
java.security.KeyFactory) and the
Converting asymmetric keys is done with this class:
Provide an infrastructure for importing and exporting keys according to the specific encoding format or parameters of the key.
KeyFactory class is an engine class, which
provides the typical method of instantiating itself:
Create a key factory capable of importing and exporting keys that were generated with the given algorithm. The class that implements the key factory comes from the named provider or is ...