Secret Keys

The secret key Ciphers will simply generate the appropriate number of random bytes for the key (there are no checks for weak keys).

The following example will generate a random double-length DESede key. Generation of a key for a different algorithm is as simple as changing the algorithm name and choosing an appropriate key length.

KeyGenerator keyGen = KeyGenerator.getInstance(“DESede”, “SAFENET”);
keyGen.init(128);
SecretKey key = keyGen.generateKey();