Explorar el Código

导出附件按用户id归集

Suxue hace 1 año
padre
commit
ddfec75201
Se han modificado 2 ficheros con 10 adiciones y 14 borrados
  1. 2 6
      Helpers/DecryptionHelper.cs
  2. 8 8
      WXUserReader.cs

+ 2 - 6
Helpers/DecryptionHelper.cs

@@ -136,10 +136,6 @@ namespace WechatBakTool.Helpers
                     throw new Exception("搜索不到微信账号,请确认用户名是否正确,如错误请重新新建工作区,务必确认账号是否正确");
                     throw new Exception("搜索不到微信账号,请确认用户名是否正确,如错误请重新新建工作区,务必确认账号是否正确");
                 }
                 }
             }
             }
-            else if (find_key_type == 3)
-            {
-                string searchString = "-----BEGIN PUBLIC KEY-----";
-            }
             return null;
             return null;
         }
         }
 
 
@@ -178,7 +174,7 @@ namespace WechatBakTool.Helpers
                 var page_bytes = BitConverter.GetBytes(page_no + 1);
                 var page_bytes = BitConverter.GetBytes(page_no + 1);
                 page_bytes.CopyTo(going_to_hashed, DEFAULT_PAGESIZE - reserved - offset + IV_SIZE);
                 page_bytes.CopyTo(going_to_hashed, DEFAULT_PAGESIZE - reserved - offset + IV_SIZE);
                 //计算分页的Hash
                 //计算分页的Hash
-                var hash_mac_compute = hmac_sha1.ComputeHash(going_to_hashed, 0, going_to_hashed.Count());
+                var hash_mac_compute = hmac_sha1.ComputeHash(going_to_hashed, 0, going_to_hashed.Length);
                 //取出分页中存储的Hash
                 //取出分页中存储的Hash
                 var hash_mac_cached = db_file_bytes.Skip((page_no * DEFAULT_PAGESIZE) + DEFAULT_PAGESIZE - reserved + IV_SIZE).Take(hash_mac_compute.Length).ToArray();
                 var hash_mac_cached = db_file_bytes.Skip((page_no * DEFAULT_PAGESIZE) + DEFAULT_PAGESIZE - reserved + IV_SIZE).Take(hash_mac_compute.Length).ToArray();
                 //对比两个Hash
                 //对比两个Hash
@@ -229,7 +225,7 @@ namespace WechatBakTool.Helpers
             return BitConverter.ToString(bytes, 0).Replace("-", string.Empty).ToLower().ToUpper();
             return BitConverter.ToString(bytes, 0).Replace("-", string.Empty).ToLower().ToUpper();
         }
         }
 
 
-        private static List<byte[]> ImgHeader = new List<byte[]>()
+        private readonly static List<byte[]> ImgHeader = new List<byte[]>()
         {
         {
             new byte[] { 0xFF, 0xD8 },//JPG
             new byte[] { 0xFF, 0xD8 },//JPG
             new byte[] { 0x89, 0x50 },//PNG
             new byte[] { 0x89, 0x50 },//PNG

+ 8 - 8
WXUserReader.cs

@@ -162,7 +162,7 @@ namespace WechatBakTool
                             }
                             }
                             else
                             else
                             {
                             {
-                                string path = Path.Combine(UserBakConfig.UserWorkspacePath, "Emoji", md5 + ".gif");
+                                string path = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Emoji", md5 + ".gif");
                                 try
                                 try
                                 {
                                 {
                                     HttpResponseMessage res = httpClient.GetAsync(url).Result;
                                     HttpResponseMessage res = httpClient.GetAsync(url).Result;
@@ -511,7 +511,7 @@ namespace WechatBakTool
             if (UserBakConfig == null)
             if (UserBakConfig == null)
                 return null;
                 return null;
 
 
-            string? tmpPath = Path.Combine(UserBakConfig.UserWorkspacePath, "Temp");
+            string? tmpPath = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Temp");
             if (!Directory.Exists(tmpPath))
             if (!Directory.Exists(tmpPath))
                 Directory.CreateDirectory(tmpPath);
                 Directory.CreateDirectory(tmpPath);
 
 
@@ -576,15 +576,15 @@ namespace WechatBakTool
             // 获取到原路径后,开始进行解密转移,只有图片和语音需要解密,解密后是直接归档目录
             // 获取到原路径后,开始进行解密转移,只有图片和语音需要解密,解密后是直接归档目录
             if (type == WXMsgType.Image || type == WXMsgType.Audio)
             if (type == WXMsgType.Image || type == WXMsgType.Audio)
             {
             {
-                path = DecryptAttachment(type, path);
+                path = DecryptAttachment(type, path, msg.StrTalker);
             }
             }
             else if (type == WXMsgType.Video || type == WXMsgType.File)
             else if (type == WXMsgType.Video || type == WXMsgType.File)
             {
             {
                 string to_dir;
                 string to_dir;
                 if (type == WXMsgType.Video)
                 if (type == WXMsgType.Video)
-                    to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Video");
+                    to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "Video");
                 else
                 else
-                    to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "File");
+                    to_dir = Path.Combine(UserBakConfig.UserWorkspacePath, msg.StrTalker, "File");
                 if (!Directory.Exists(to_dir))
                 if (!Directory.Exists(to_dir))
                     Directory.CreateDirectory(to_dir);
                     Directory.CreateDirectory(to_dir);
                 FileInfo fileInfo = new FileInfo(path);
                 FileInfo fileInfo = new FileInfo(path);
@@ -615,7 +615,7 @@ namespace WechatBakTool
             return path;
             return path;
 
 
         }
         }
-        public string? DecryptAttachment(WXMsgType type, string path)
+        public string? DecryptAttachment(WXMsgType type, string path,string username)
         {
         {
             if (UserBakConfig == null)
             if (UserBakConfig == null)
                 return null;
                 return null;
@@ -624,7 +624,7 @@ namespace WechatBakTool
             switch (type)
             switch (type)
             {
             {
                 case WXMsgType.Image:
                 case WXMsgType.Image:
-                    string img_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Image");
+                    string img_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Image");
                     if (!Directory.Exists(img_dir))
                     if (!Directory.Exists(img_dir))
                         Directory.CreateDirectory(img_dir);
                         Directory.CreateDirectory(img_dir);
                     // 图片的路径是相对路径,需要加上资源目录
                     // 图片的路径是相对路径,需要加上资源目录
@@ -636,7 +636,7 @@ namespace WechatBakTool
                     file_path = DecryptionHelper.SaveDecImage(decFileByte, path, img_dir, decFiletype);
                     file_path = DecryptionHelper.SaveDecImage(decFileByte, path, img_dir, decFiletype);
                     break;
                     break;
                 case WXMsgType.Audio:
                 case WXMsgType.Audio:
-                    string audio_dir = Path.Combine(UserBakConfig.UserWorkspacePath, "Audio");
+                    string audio_dir = Path.Combine(UserBakConfig.UserWorkspacePath, username, "Audio");
                     if (!Directory.Exists(audio_dir))
                     if (!Directory.Exists(audio_dir))
                         Directory.CreateDirectory(audio_dir);
                         Directory.CreateDirectory(audio_dir);
                     FileInfo fileInfo = new FileInfo(path);
                     FileInfo fileInfo = new FileInfo(path);