.net 混淆加密项目中js文件夹

加密

   var url = $"https://www.jshaman.com:4430/submit_js_code/";//js混淆加密接口
   var httpClient = _httpClientFactory.CreateClient();
   var path = $"D:/js/pages/";
   var childPaths = Directory.GetDirectories(path).ToList();
   foreach (var p in childPaths)
   {
       if (!Directory.Exists(p.Replace("pages", "encryptionpages"))) Directory.CreateDirectory(p.Replace("pages", "encryptionpages"));
       var childFiles = Directory.GetFiles(p).ToList();
       foreach (var cf in childFiles)
       {
           Thread.Sleep(3000);//接口调用频繁限制
           string jsContent = CommonHelper.GetFileContent(cf);
           Dictionary<string, string> obj = new Dictionary<string, string> { { "js_code", jsContent }, { "vip_code", "free" } };
           FormUrlEncodedContent content = new FormUrlEncodedContent(obj);
           HttpResponseMessage response = await httpClient.PostAsync(url, content);
           var resultStr = await response.Content.ReadAsStringAsync();
           var objectInfo = JsonConvert.DeserializeObject<JObject>(resultStr);
           var encryptionContent = objectInfo["content"].ToString();
           if (!string.IsNullOrEmpty(encryptionContent))
           {
               byte[] array = Encoding.UTF8.GetBytes(encryptionContent);
               using (FileStream fileStream = new FileStream(cf.Replace("pages", "encryptionpages"), FileMode.OpenOrCreate))
               {
                   fileStream.Write(array, 0, array.Length);
               }
           }
       }
   }

 

posted @ 2024-09-09 15:42  北极星下落不明  阅读(9)  评论(0)    收藏  举报