jiemiUtils.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using NPOI.OpenXmlFormats.Dml.Diagram;
  2. using NPOI.OpenXmlFormats.Shared;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace SiteCore.taobao
  11. {
  12. public class jiemiUtils
  13. {
  14. [DllImport("DrvInterface64.dll", CharSet = CharSet.Unicode)]
  15. public static extern uint DecFile(string filename);
  16. [DllImport("DrvInterface64.dll", CharSet = CharSet.Unicode)]
  17. public static extern int IsFileEncrypted(string filename);//返回1为加密,0为未被加密
  18. [DllImport("DrvInterface64.dll", CharSet = CharSet.Ansi)]
  19. public static extern void CreateUserKey(StringBuilder key, int len);
  20. [DllImport("DrvInterface64.dll", CharSet = CharSet.Ansi)]
  21. public static extern int InitAesKey(StringBuilder key, int len);
  22. [DllImport("DrvInterface64.dll")]
  23. public static extern int IsInitedAesKey();
  24. public static void ossFileDecrypt(string filePath)
  25. {
  26. int IsFileEncrypt = IsFileEncrypted(filePath);
  27. if (IsFileEncrypt == 1 && File.Exists(filePath))
  28. {
  29. string key = "gBQnlxiBb7MthH9644V0W0pFwqYZgyy7";
  30. var sb = new StringBuilder(key);
  31. //Linux系统的接口要调用一次,Windows系统要调用两次
  32. CreateUserKey(sb, key.Length);
  33. CreateUserKey(sb, key.Length); //破解用dse生成的文件,需要调2次。
  34. int result = InitAesKey(sb, sb.Length);
  35. result = IsInitedAesKey();
  36. if (result != 1)
  37. {
  38. }
  39. uint a = DecFile(filePath);
  40. if (a != 0)
  41. {
  42. }
  43. }
  44. }
  45. }
  46. }