我想編寫一個自動解密我的WhatsApp數據庫的Android應用程序,所以我跟着this教程並將其翻譯成Java。但後來我注意到Android上沒有openssl二進制文件,所以我問谷歌如何手動解密aes,但我找不到有用的東西。Android上的Whatsapp數據庫解密
所以基本上我得到這個shell命令
openssl enc -aes-256-cbc -d -nosalt -nopad -bufsize 16384 -in msgstore.db.crypt7.nohdr -K $k -iv $iv > msgstore.db
與$ 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[] d = new byte[8];
while ((b = cis.read(d)) != -1) {
fos.write(d, 0, b);
}
fos.flush();
fos.close();
cis.close();
}
請幫助我,如果你能提前:)
感謝,柚子
什麼是堆棧跟蹤和exce ption錯誤信息? –
異常消息是「InvalidKeyException:不支持的密鑰大小:64字節」 – Citron
只是爲了闡明:您發佈的Java代碼在您的PC上執行,但在您的Android設備上執行時無效? –