Android阅读WhatsApp数据(Android Read WhatsApp Data)
到目前为止,我GOOGLE了很多关于解密扩展名为
whatsapp db file
,.db.crypt5
但没有办法为我工作。 我尝试了一个Crypto.class ,它可以在Stackoverflow链接中看到很多内容来读取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 。
我在哪里做错了需要帮助?
So far I googled a lot about decrypting
whatsapp db file
with extension as,.db.crypt5
but no approach worked for me. I tried a Crypto.class which can be seen a lot in stackoverflow links to read WhatsApp database file, but that file also did not work for me.
This is my 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; } }
and this is how I am calling the constructor in my activity:
Crypto c = new Crypto("/sdcard/WhatsApp/Databases/msgstore.db.crypt5", "/sdcard/My_Folder_Name/watsapp");
I just want to decrypt this file and see all chats. For testing, I am trying on this file msgstore.db.crypt5.
I need help where I am doing wrong?
原文:https://stackoverflow.com/questions/22551704
最满意答案
你应该使用dicts列表:
[ {'id': 0, 'ISIN': '', 'Currency': ''}, {'id': 1, 'ISIN': '', 'Currency': ''} ]
或者如果你想要字典:
{ 0: {'ISIN': '', 'Currency': ''}, 1: {'ISIN': '', 'Currency': ''} }
或(部分基于Marco的建议):
{ 0: [26545555, 'Eur', 0.12345], 1: [26545555, 'Eur', 0.12345] }
但我个人更喜欢第二种变体,如果你需要通过ID访问元素。
You should use list of dicts:
[ {'id': 0, 'ISIN': '', 'Currency': ''}, {'id': 1, 'ISIN': '', 'Currency': ''} ]
or if you want dict:
{ 0: {'ISIN': '', 'Currency': ''}, 1: {'ISIN': '', 'Currency': ''} }
or(partly based on Marco's suggestion):
{ 0: [26545555, 'Eur', 0.12345], 1: [26545555, 'Eur', 0.12345] }
But personally I prefer second variant if you will need to access elements by ID.
相关问答
更多-
像Json这样的Python字典(Python dictionary like Json)[2021-08-27]
你应该使用dicts列表: [ {'id': 0, 'ISIN': '', 'Currency': ''}, {'id': 1, 'ISIN': '', 'Currency': ''} ] 或者如果你想要字典: { 0: {'ISIN': '', 'Currency': ''}, 1: {'ISIN': '', 'Currency': ''} } 或(部分基于Marco的建议): { 0: [26545555, 'Eur', 0.12345], 1: [26545555, 'Eur', 0.12 ... -
您只需要一个dump d = OrderedDict([(1, {'test': datetime.datetime(2016, 2, 1, 20, 21, 27)}), (2, 20)]) with open("my_file.json","w") as f: json.dump(d, f, default=date_handler) You need only one dump d = OrderedDict([(1, {'test': datetime.datetime(2016, 2, ...
-
这是我写入JSON文件并从中读取的方式: import json from pprint import pprint dictionary = {"Europe": {"France": (10,5), "Germany": (15,5), "Italy": (5,15)}, "North-America": { "USA": (20,0), ...
-
尝试这个 - es_res = { u'hits':{ u'hits':[ { u'_score':1.0, u'_type':u'input', u'_id':u'1', u'_source':{ u'message':u'I really love fake news tho.' }, ...
-
编辑请尝试这种方法: import re # pattern to get values of UFD, DF, and IE from dict1 p1 = '(?s){\s+"AP":\s+{\s+"UFD":\s+(.*?),\s+"DF":\s+"(.*?)"\s+},\s+"IE":\s+(.*?),\s+"\$":\s+"PDAE"\s+}' # pattern to match dict2 p2 = '({[\s\S]+?"UFD":\s+)(.*?)(,\s+"DF":\s+")(.*?)( ...
-
IIUC你需要加入到一个,你可以使用update : a = {"cars": 1, "houses": 2, "schools": 3, "stores": 4} b = {"Pens": 1, "Pencils": 2, "Paper": 3} a.update(b) print(a) 输出将如下所示: {'Paper': 3, 'cars': 1, 'Pens': 1, 'stores': 4, 'Pencils': 2, 'schools': 3, 'houses': 2} 要创建全新的dic ...
-
dict(measurement="Equipment1", dict(pressure=5.5),dict(MachineType="Type1"),timestamp=time.time())) 在这里,您缺少某些字典值的键名(“fields”和“tags”)。 dict(measurement="Equipment1", fields=dict(pressure=5.5), tags=dict(MachineType="Type1"), timestamp=time.time())) 或者你可以更 ...
-
加载json时,会在列表中获得json对象。 所以你使用for循环迭代该列表 for item in json_data: 此时item指的是json对象不列出,你试图通过使用来访问代码中的列表 name = entry[0]; 还有一件事不要在python中使用(;)结束语句而你正在使用它 你需要从字典中获取数据,它应该是这样的 for item in json_data: name=item.get('name') id=item.get('id') 你的代码应该是这样的 impo ...
-
要解决原始问题,例如: with open("pathtomyfile", "w") as f: for item in r.json or []: try: f.write(item['repository']['name'] + "\n") except KeyError: # you might have to adjust what you are writing accordingly pass # or ...
-
您必须使用python语法,如下所示: >>> print response['swell']['components']['primary']['direction'] 222.5 You have to use python syntax as follows: >>> print response['swell']['components']['primary']['direction'] 222.5