我想写一个自动解密我的Whatsapp数据库的Android应用程序,所以我按照本教程将其翻译成Java.但后来我注意到Android上没有openssl二进制文件所以我问google如何手动解密aes但我找不到有用的东西.
所以基本上我得到了这个shell命令
openssl enc -aes-256-cbc -d -nosalt -nopad -bufsize 16384 -in msgstore.db.crypt7.nohdr -K $k -iv $iv > msgstore.db
Run Code Online (Sandbox Code Playgroud)
$ k是64位十六进制字符串.但是当我尝试将它用作aes解密的密钥时,我得到一个带有"Unsupported key size:64 bytes"消息的InvalidKeyException.当我在我的电脑上执行此命令时,我工作得很好.
我目前正在使用这个java代码来解密数据库,它在cipher.init失败:
public void decryptDatabase(String k, String iv)
throws InvalidKeyException, InvalidAlgorithmParameterException,
NoSuchAlgorithmException, NoSuchPaddingException, IOException {
File extStore = Environment.getExternalStorageDirectory();
FileInputStream fis = new FileInputStream(extStore
+ "/WhatsApp/Databases/msgstore.db.crypt7.nohdr");
FileOutputStream fos = new FileOutputStream(extStore + "/Decrypted.db");
SecretKeySpec sks = new SecretKeySpec(k.getBytes(), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
cipher.init(Cipher.DECRYPT_MODE, sks,
new IvParameterSpec(iv.getBytes()));
CipherInputStream cis = new CipherInputStream(fis, cipher);
int b;
byte[] …Run Code Online (Sandbox Code Playgroud)