到目前为止,我在谷歌上搜索了很多与解密拓展名为 db.crypt5
的 whatsapp db file
有关的内容,但没有一种方法适用于我。我尝试使用 Crypto.class 来读取WhatsApp数据库文件,但该文件对我也无效。以下是我的Crypto.class:
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import javax.crypto.Cipher;
import javax.crypto.CipherInputStream;
import javax.crypto.spec.SecretKeySpec;
import android.util.Log;
public class Crypto
{
public FileInputStream mIn;
public FileOutputStream mOut;
public Crypto(String fileIn, String fileOut)
{
try
{
mIn = new FileInputStream(new File(fileIn));
mOut = new FileOutputStream(new File(fileOut));
decrypt(mIn, mOut);
}
catch (Exception e)
{
e.printStackTrace();
}
}
public static void decrypt(InputStream in, FileOutputStream out) throws Exception
{
final String string = "346a23652a46392b4d73257c67317e352e3372482177652c";
byte[] hexAsBytes = hexStringToByteArray(string);
SecretKeySpec keySpec = new SecretKeySpec(hexAsBytes, "AES");
Cipher cipher = Cipher.getInstance("AES");
cipher.init(Cipher.DECRYPT_MODE, keySpec);
in = new CipherInputStream(in, cipher);
byte[] buffer = new byte[24];
int bytesRead;
while ((bytesRead = in.read(buffer)) != -1)
{
out.write(buffer, 0, bytesRead);
String si = new String(buffer);
Log.d("Crypto", si);
}
}
public static byte[] hexStringToByteArray(String s)
{
int len = s.length();
byte[] data = new byte[len / 2];
for(int i = 0; i < len; i += 2)
{
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i + 1), 16));
}
return data;
}
}
这是我在活动中调用构造函数的方法:
Crypto c = new Crypto("/sdcard/WhatsApp/Databases/msgstore.db.crypt5", "/sdcard/My_Folder_Name/watsapp");
我只想解密这个文件并查看所有聊天记录。为了测试,我正在尝试使用此文件msgstore.db.crypt5。
我需要帮助,不知道哪里出错了?