private static byte[] decrypt(String algorithm, byte[] key, byte[] data) {
BlockCipher cipher = CipherFactory.getBlockCipher(algorithm);
byte[] newKey = getPaddedArrayCopy(key, cipher.getKeyLength());
cipher.setKey(newKey);
byte[] newData = getPaddedArrayCopy(data, BlockCipher.ALIGN);
cipher.decrypt(newData, 0, newData.length);
return newData;
}
private static byte[] encrypt(String algorithm, byte[] key, byte[] data) {
BlockCipher cipher = CipherFactory.getBlockCipher(algorithm);