public class TripleDESKeyGenerator extends VarLengthKeyGenerator
An application uses
KeyGenerator key_gen = KeyGenerator.getInstance("TripleDES");
for creating a KeyGenerator object for the TripleDES algorithm. For actually
generating the requested secret TripleDES key from the KeyGenerator object
just created, an application calls the generateKey method after
having initialized the generator with some random seed or relied on the
default system-provided source of randomness:
SecretKey triple_des_key = key_gen.generateKey();
A TripleDES key is composed of three DES keys. For extracting the inherent DES
keys, an application may use the getEncoded method to get a byte
array representation of the TripleDES key and subsequently split it accordingly:
des key1 = first 8 bytes of key des key2 = second 8 bytes of key des key3 = first 8 bytes of key in case of 2 key triple DES, third 8 bytes otherwise
KeyGenerator,
KeyGeneratorSpi,
SecretKey,
SecretKey,
DESKeyGenerator,
TripleDES| Constructor and Description |
|---|
TripleDESKeyGenerator() |
| Modifier and Type | Method and Description |
|---|---|
protected javax.crypto.SecretKey |
engineGenerateKey()
Generates a new key.
|
protected void |
engineInit(int strength,
java.security.SecureRandom random)
Initializes this key generator for the given strength with the given random seed.
|
engineInit, engineInitprotected void engineInit(int strength,
java.security.SecureRandom random)
engineInit in class VarLengthKeyGeneratorstrength - the strength of the key to be created; if -1, the default length (192) is usedrandom - the random seedjava.security.InvalidParameterException - if the supplied key strength is not -1 or 112 or 128 or 168 or 192protected javax.crypto.SecretKey engineGenerateKey()
VarLengthKeyGeneratorengineGenerateKey in class VarLengthKeyGenerator