public void performTest() { DESKeyGenerator keyGen = new DESKeyGenerator(); keyGen.init(new KeyGenerationParameters(new SecureRandom(), 56)); byte[] kB = keyGen.generateKey(); if (kB.length != 8) { fail("DES bit key wrong length."); } }
private byte[] generateKey() { SecureRandom random = new SecureRandom(); random.setSeed(UUID.randomUUID().toString().getBytes()); KeyGenerationParameters generationParameters = new KeyGenerationParameters(random, DESParameters.DES_KEY_LENGTH * 8); DESKeyGenerator generator = new DESKeyGenerator(); generator.init(generationParameters); return Hex.encode(generator.generateKey()); }
public KeyGenerator() { super("DES", 64, new DESKeyGenerator()); }