I have an encrypted file in server using OpenSSL command:
openssl enc -aes-256-ecb -salt -in ori.pdf -out encrypted.pdf -pass pass:testpassword -p
Below is the key and salt showed after the encryption done:
salt=BE1EFCBAE984CB24
key=50B62ECEF1B777353372A44CDDC463987815F783E39D68B8EE6A0AB74A79C7FA
I had tried to decrypt if with below decryption:
String key = "50B62ECEF1B777353372A44CDDC463987815F783E39D68B8EE6A0AB74A79C7FA";
byte[] keyBytes = key.getBytes("UTF-8");
SecretKey keySpec = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS7Padding");
cipher.init(Cipher.DECRYPT_MODE, keySpec);
buffer = cipher.doFinal(buffer);
How to decrypt the encrypted file in Android?