// Create the cipher according to its algorithm
cipher = Cipher.getInstance("DESede/CBC/NoPadding");
byte[] actualKey = new byte[24];
System.arraycopy(keydata, 0, actualKey, 0, 24);
keyspec = new DESedeKeySpec(actualKey);
key = SecretKeyFactory.getInstance("DESede").generateSecret(keyspec);
cipher.init(((mode == ENCRYPT_MODE) ? Cipher.ENCRYPT_MODE
: Cipher.DECRYPT_MODE), key,
new IvParameterSpec(iv, 0, cipher.getBlockSize()));
} catch (NoSuchPaddingException nspe) {