/** * Generate des key. * * @param file the file * @throws java.io.IOException Signals that an I/O exception has occurred. */ public static void generateDESKey(String file) throws IOException { DESedeKeyGenerator kg = new DESedeKeyGenerator(); KeyGenerationParameters kgp = new KeyGenerationParameters( new SecureRandom(), DESedeParameters.DES_EDE_KEY_LENGTH * 8); kg.init(kgp); byte[] key = kg.generateKey(); BufferedOutputStream keystream = new BufferedOutputStream(new FileOutputStream(file)); byte[] keyhex = Hex.encode(key); keystream.write(keyhex, 0, keyhex.length); keystream.flush(); keystream.close(); }
public static KeyGenerator create() { final SecureRandom random = new SecureRandom(); final KeyGenerationParameters parameters = new KeyGenerationParameters( random, DESedeParameters.DES_EDE_KEY_LENGTH * 8); final DESedeKeyGenerator keyGenerator = new DESedeKeyGenerator(); keyGenerator.init(parameters); return new KeyGenerator(keyGenerator); }
public KeyGenerator() { super("DESede", 192, new DESedeKeyGenerator()); }
public KeyGenerator3() { super("DESede3", 192, new DESedeKeyGenerator()); }
private KeyGenerator(final DESedeKeyGenerator keyGenerator) { this.keyGenerator = keyGenerator; }