Browse Source

完成文件加密功能

yuzhengyang 8 years ago
parent
commit
0964ba1b4d
92 changed files with 141 additions and 165 deletions
  1. 3 4
      Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/MainForm.cs
  2. 0 0
      Fork.Net/Temp/Y.Controls.Net20/Class1.cs
  3. 0 0
      Fork.Net/Temp/Y.Controls.Net20/Container/FlexiblePanel.Designer.cs
  4. 0 0
      Fork.Net/Temp/Y.Controls.Net20/Container/FlexiblePanel.cs
  5. 0 0
      Fork.Net/Temp/Y.Controls.Net20/Properties/AssemblyInfo.cs
  6. 0 0
      Fork.Net/Temp/Y.Controls.Net20/Y.Controls.Net20.csproj
  7. 0 0
      Fork.Net/Temp/Y.Utils.Net20/AppUtils/AppUnique.cs
  8. 0 0
      Fork.Net/Temp/Y.Utils.Net20/ComputerUtils/RegisterTool.cs
  9. 0 0
      Fork.Net/Temp/Y.Utils.Net20/EncryptUtils/AesTool.cs
  10. 0 0
      Fork.Net/Temp/Y.Utils.Net20/EncryptUtils/DesTool.cs
  11. 0 0
      Fork.Net/Temp/Y.Utils.Net20/EnumUtils/FlagsEnumTool.cs
  12. 0 0
      Fork.Net/Temp/Y.Utils.Net20/FileUtils/DirTool.cs
  13. 0 0
      Fork.Net/Temp/Y.Utils.Net20/FileUtils/FileCode.cs
  14. 0 0
      Fork.Net/Temp/Y.Utils.Net20/FileUtils/FileTool.cs
  15. 0 0
      Fork.Net/Temp/Y.Utils.Net20/HookUtils/UserActivityHook.cs
  16. 0 0
      Fork.Net/Temp/Y.Utils.Net20/HttpUtils/HttpTool.cs
  17. 0 0
      Fork.Net/Temp/Y.Utils.Net20/ImageUtils/ImageTool.cs
  18. 0 0
      Fork.Net/Temp/Y.Utils.Net20/ImageUtils/ThunbnailTool.cs
  19. 0 0
      Fork.Net/Temp/Y.Utils.Net20/JsonUtils/JsonTool.cs
  20. 0 0
      Fork.Net/Temp/Y.Utils.Net20/ListUtils/ListTool.cs
  21. 0 0
      Fork.Net/Temp/Y.Utils.Net20/LogUtils/Log.cs
  22. 0 0
      Fork.Net/Temp/Y.Utils.Net20/LogUtils/LogType.cs
  23. 0 0
      Fork.Net/Temp/Y.Utils.Net20/Properties/AssemblyInfo.cs
  24. 0 0
      Fork.Net/Temp/Y.Utils.Net20/StringUtils/SimilarString.cs
  25. 0 0
      Fork.Net/Temp/Y.Utils.Net20/StringUtils/StringTool.cs
  26. 0 0
      Fork.Net/Temp/Y.Utils.Net20/TimeUtils/DateTimeConvert.cs
  27. 0 0
      Fork.Net/Temp/Y.Utils.Net20/TimeUtils/DateTimeTool.cs
  28. 0 0
      Fork.Net/Temp/Y.Utils.Net20/TxtUtils/IniTool.cs
  29. 0 0
      Fork.Net/Temp/Y.Utils.Net20/TxtUtils/TxtTool.cs
  30. 0 0
      Fork.Net/Temp/Y.Utils.Net20/WindowsAPI/ComputerAFK.cs
  31. 0 0
      Fork.Net/Temp/Y.Utils.Net20/WindowsAPI/WindowInfo.cs
  32. 0 0
      Fork.Net/Temp/Y.Utils.Net20/Y.Utils.Net20.csproj
  33. 0 0
      Fork.Net/Temp/Y.Utils.Net20/packages.config
  34. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/App.config
  35. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.Designer.cs
  36. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.cs
  37. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.resx
  38. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/LegoRun.cs
  39. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Program.cs
  40. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/AssemblyInfo.cs
  41. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Resources.Designer.cs
  42. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Resources.resx
  43. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Settings.Designer.cs
  44. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Settings.settings
  45. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Waka.Lego.Baidu.csproj
  46. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/App.config
  47. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.Designer.cs
  48. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.cs
  49. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.resx
  50. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form2.Designer.cs
  51. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form2.cs
  52. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/LegoRun.cs
  53. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/PoliceAcess.png
  54. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Program.cs
  55. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/AssemblyInfo.cs
  56. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Resources.Designer.cs
  57. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Resources.resx
  58. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Settings.Designer.cs
  59. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Settings.settings
  60. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/Waka.Lego.Icon.csproj
  61. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Icon/pa.ico
  62. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/App.config
  63. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.Designer.cs
  64. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.cs
  65. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.resx
  66. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/LegoRun.cs
  67. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Program.cs
  68. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/AssemblyInfo.cs
  69. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Resources.Designer.cs
  70. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Resources.resx
  71. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Settings.Designer.cs
  72. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Settings.settings
  73. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego.Music/Waka.Lego.Music.csproj
  74. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/App.config
  75. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Commons/R.cs
  76. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Form1.Designer.cs
  77. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Form1.cs
  78. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Form1.resx
  79. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Program.cs
  80. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/AssemblyInfo.cs
  81. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/Resources.Designer.cs
  82. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/Resources.resx
  83. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/Settings.Designer.cs
  84. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/Settings.settings
  85. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Properties/app.manifest
  86. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.Designer.cs
  87. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.cs
  88. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.resx
  89. 0 0
      Fork.Net/Waka.Plugin/Waka.Lego/Waka.Lego.csproj
  90. 31 1
      Fork.Net/Y.Utils/DataUtils/EncryptUtils/AesTool.cs
  91. 106 160
      Fork.Net/Y.Utils/IOUtils/FileUtils/FileEncryptTool.cs
  92. 1 0
      Fork.Net/Y.Utils/Y.Utils.csproj

+ 3 - 4
Fork.Net/Oreo.Plugins/Oreo.FileMan/Views/MainForm.cs

@@ -33,12 +33,11 @@ namespace Oreo.FileMan.Views
                 string file = fileDialog.FileName;
                 if (File.Exists(file))
                 {
-                    string md5 = fct.GetMD5(file);
                     string newfile = file + ".fmk";
 
                     if (!File.Exists(newfile))
                     {
-                        if (FileEncryptTool.Encrypt(file, newfile, pwd))
+                        if (FileEncryptTool.Encrypt(file, newfile, pwd) > 0)
                         {
                             MessageBox.Show("恭喜你,加密成功。", "加密成功");
                         }
@@ -53,7 +52,7 @@ namespace Oreo.FileMan.Views
 
         private void BtFileDecrypt_Click(object sender, EventArgs e)
         {
-            string pwd = "123456789012";
+            string pwd = "1234567890121";
             string[] fileInfo = new string[128];
             OpenFileDialog fileDialog = new OpenFileDialog();
             fileDialog.Title = "请选择要解密的文件";
@@ -66,7 +65,7 @@ namespace Oreo.FileMan.Views
                     string newfile = file.Substring(0, file.Length - ".fmk".Length);
                     if (!File.Exists(newfile))
                     {
-                        if (FileEncryptTool.Decrypt(file, newfile, pwd))
+                        if (FileEncryptTool.Decrypt(file, newfile, pwd) > 0)
                         {
                             MessageBox.Show("恭喜你,解密成功。", "解密成功");
                         }

Fork.Net/Y.Controls.Net20/Class1.cs → Fork.Net/Temp/Y.Controls.Net20/Class1.cs


Fork.Net/Y.Controls.Net20/Container/FlexiblePanel.Designer.cs → Fork.Net/Temp/Y.Controls.Net20/Container/FlexiblePanel.Designer.cs


Fork.Net/Y.Controls.Net20/Container/FlexiblePanel.cs → Fork.Net/Temp/Y.Controls.Net20/Container/FlexiblePanel.cs


Fork.Net/Y.Controls.Net20/Properties/AssemblyInfo.cs → Fork.Net/Temp/Y.Controls.Net20/Properties/AssemblyInfo.cs


Fork.Net/Y.Controls.Net20/Y.Controls.Net20.csproj → Fork.Net/Temp/Y.Controls.Net20/Y.Controls.Net20.csproj


Fork.Net/Y.Utils.Net20/AppUtils/AppUnique.cs → Fork.Net/Temp/Y.Utils.Net20/AppUtils/AppUnique.cs


Fork.Net/Y.Utils.Net20/ComputerUtils/RegisterTool.cs → Fork.Net/Temp/Y.Utils.Net20/ComputerUtils/RegisterTool.cs


Fork.Net/Y.Utils.Net20/EncryptUtils/AesTool.cs → Fork.Net/Temp/Y.Utils.Net20/EncryptUtils/AesTool.cs


Fork.Net/Y.Utils.Net20/EncryptUtils/DesTool.cs → Fork.Net/Temp/Y.Utils.Net20/EncryptUtils/DesTool.cs


Fork.Net/Y.Utils.Net20/EnumUtils/FlagsEnumTool.cs → Fork.Net/Temp/Y.Utils.Net20/EnumUtils/FlagsEnumTool.cs


Fork.Net/Y.Utils.Net20/FileUtils/DirTool.cs → Fork.Net/Temp/Y.Utils.Net20/FileUtils/DirTool.cs


Fork.Net/Y.Utils.Net20/FileUtils/FileCode.cs → Fork.Net/Temp/Y.Utils.Net20/FileUtils/FileCode.cs


Fork.Net/Y.Utils.Net20/FileUtils/FileTool.cs → Fork.Net/Temp/Y.Utils.Net20/FileUtils/FileTool.cs


Fork.Net/Y.Utils.Net20/HookUtils/UserActivityHook.cs → Fork.Net/Temp/Y.Utils.Net20/HookUtils/UserActivityHook.cs


Fork.Net/Y.Utils.Net20/HttpUtils/HttpTool.cs → Fork.Net/Temp/Y.Utils.Net20/HttpUtils/HttpTool.cs


Fork.Net/Y.Utils.Net20/ImageUtils/ImageTool.cs → Fork.Net/Temp/Y.Utils.Net20/ImageUtils/ImageTool.cs


Fork.Net/Y.Utils.Net20/ImageUtils/ThunbnailTool.cs → Fork.Net/Temp/Y.Utils.Net20/ImageUtils/ThunbnailTool.cs


Fork.Net/Y.Utils.Net20/JsonUtils/JsonTool.cs → Fork.Net/Temp/Y.Utils.Net20/JsonUtils/JsonTool.cs


Fork.Net/Y.Utils.Net20/ListUtils/ListTool.cs → Fork.Net/Temp/Y.Utils.Net20/ListUtils/ListTool.cs


Fork.Net/Y.Utils.Net20/LogUtils/Log.cs → Fork.Net/Temp/Y.Utils.Net20/LogUtils/Log.cs


Fork.Net/Y.Utils.Net20/LogUtils/LogType.cs → Fork.Net/Temp/Y.Utils.Net20/LogUtils/LogType.cs


Fork.Net/Y.Utils.Net20/Properties/AssemblyInfo.cs → Fork.Net/Temp/Y.Utils.Net20/Properties/AssemblyInfo.cs


Fork.Net/Y.Utils.Net20/StringUtils/SimilarString.cs → Fork.Net/Temp/Y.Utils.Net20/StringUtils/SimilarString.cs


Fork.Net/Y.Utils.Net20/StringUtils/StringTool.cs → Fork.Net/Temp/Y.Utils.Net20/StringUtils/StringTool.cs


Fork.Net/Y.Utils.Net20/TimeUtils/DateTimeConvert.cs → Fork.Net/Temp/Y.Utils.Net20/TimeUtils/DateTimeConvert.cs


Fork.Net/Y.Utils.Net20/TimeUtils/DateTimeTool.cs → Fork.Net/Temp/Y.Utils.Net20/TimeUtils/DateTimeTool.cs


Fork.Net/Y.Utils.Net20/TxtUtils/IniTool.cs → Fork.Net/Temp/Y.Utils.Net20/TxtUtils/IniTool.cs


Fork.Net/Y.Utils.Net20/TxtUtils/TxtTool.cs → Fork.Net/Temp/Y.Utils.Net20/TxtUtils/TxtTool.cs


Fork.Net/Y.Utils.Net20/WindowsAPI/ComputerAFK.cs → Fork.Net/Temp/Y.Utils.Net20/WindowsAPI/ComputerAFK.cs


Fork.Net/Y.Utils.Net20/WindowsAPI/WindowInfo.cs → Fork.Net/Temp/Y.Utils.Net20/WindowsAPI/WindowInfo.cs


Fork.Net/Y.Utils.Net20/Y.Utils.Net20.csproj → Fork.Net/Temp/Y.Utils.Net20/Y.Utils.Net20.csproj


Fork.Net/Y.Utils.Net20/packages.config → Fork.Net/Temp/Y.Utils.Net20/packages.config


Fork.Net/Waka.Lego.Baidu/App.config → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/App.config


Fork.Net/Waka.Lego.Baidu/Form1.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.Designer.cs


Fork.Net/Waka.Lego.Baidu/Form1.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.cs


Fork.Net/Waka.Lego.Baidu/Form1.resx → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Form1.resx


Fork.Net/Waka.Lego.Baidu/LegoRun.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/LegoRun.cs


Fork.Net/Waka.Lego.Baidu/Program.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Program.cs


Fork.Net/Waka.Lego.Baidu/Properties/AssemblyInfo.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/AssemblyInfo.cs


Fork.Net/Waka.Lego.Baidu/Properties/Resources.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Resources.Designer.cs


Fork.Net/Waka.Lego.Baidu/Properties/Resources.resx → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Resources.resx


Fork.Net/Waka.Lego.Baidu/Properties/Settings.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Settings.Designer.cs


Fork.Net/Waka.Lego.Baidu/Properties/Settings.settings → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Properties/Settings.settings


Fork.Net/Waka.Lego.Baidu/Waka.Lego.Baidu.csproj → Fork.Net/Waka.Plugin/Waka.Lego.Baidu/Waka.Lego.Baidu.csproj


Fork.Net/Waka.Lego.Icon/App.config → Fork.Net/Waka.Plugin/Waka.Lego.Icon/App.config


Fork.Net/Waka.Lego.Icon/Form1.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.Designer.cs


Fork.Net/Waka.Lego.Icon/Form1.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.cs


Fork.Net/Waka.Lego.Icon/Form1.resx → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form1.resx


Fork.Net/Waka.Lego.Icon/Form2.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form2.Designer.cs


Fork.Net/Waka.Lego.Icon/Form2.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Form2.cs


Fork.Net/Waka.Lego.Icon/LegoRun.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/LegoRun.cs


Fork.Net/Waka.Lego.Icon/PoliceAcess.png → Fork.Net/Waka.Plugin/Waka.Lego.Icon/PoliceAcess.png


Fork.Net/Waka.Lego.Icon/Program.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Program.cs


Fork.Net/Waka.Lego.Icon/Properties/AssemblyInfo.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/AssemblyInfo.cs


Fork.Net/Waka.Lego.Icon/Properties/Resources.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Resources.Designer.cs


Fork.Net/Waka.Lego.Icon/Properties/Resources.resx → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Resources.resx


Fork.Net/Waka.Lego.Icon/Properties/Settings.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Settings.Designer.cs


Fork.Net/Waka.Lego.Icon/Properties/Settings.settings → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Properties/Settings.settings


Fork.Net/Waka.Lego.Icon/Waka.Lego.Icon.csproj → Fork.Net/Waka.Plugin/Waka.Lego.Icon/Waka.Lego.Icon.csproj


Fork.Net/Waka.Lego.Icon/pa.ico → Fork.Net/Waka.Plugin/Waka.Lego.Icon/pa.ico


Fork.Net/Waka.Lego.Music/App.config → Fork.Net/Waka.Plugin/Waka.Lego.Music/App.config


Fork.Net/Waka.Lego.Music/Form1.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.Designer.cs


Fork.Net/Waka.Lego.Music/Form1.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.cs


Fork.Net/Waka.Lego.Music/Form1.resx → Fork.Net/Waka.Plugin/Waka.Lego.Music/Form1.resx


Fork.Net/Waka.Lego.Music/LegoRun.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/LegoRun.cs


Fork.Net/Waka.Lego.Music/Program.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Program.cs


Fork.Net/Waka.Lego.Music/Properties/AssemblyInfo.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/AssemblyInfo.cs


Fork.Net/Waka.Lego.Music/Properties/Resources.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Resources.Designer.cs


Fork.Net/Waka.Lego.Music/Properties/Resources.resx → Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Resources.resx


Fork.Net/Waka.Lego.Music/Properties/Settings.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Settings.Designer.cs


Fork.Net/Waka.Lego.Music/Properties/Settings.settings → Fork.Net/Waka.Plugin/Waka.Lego.Music/Properties/Settings.settings


Fork.Net/Waka.Lego.Music/Waka.Lego.Music.csproj → Fork.Net/Waka.Plugin/Waka.Lego.Music/Waka.Lego.Music.csproj


Fork.Net/Waka.Lego/App.config → Fork.Net/Waka.Plugin/Waka.Lego/App.config


Fork.Net/Waka.Lego/Commons/R.cs → Fork.Net/Waka.Plugin/Waka.Lego/Commons/R.cs


Fork.Net/Waka.Lego/Form1.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego/Form1.Designer.cs


Fork.Net/Waka.Lego/Form1.cs → Fork.Net/Waka.Plugin/Waka.Lego/Form1.cs


Fork.Net/Waka.Lego/Form1.resx → Fork.Net/Waka.Plugin/Waka.Lego/Form1.resx


Fork.Net/Waka.Lego/Program.cs → Fork.Net/Waka.Plugin/Waka.Lego/Program.cs


Fork.Net/Waka.Lego/Properties/AssemblyInfo.cs → Fork.Net/Waka.Plugin/Waka.Lego/Properties/AssemblyInfo.cs


Fork.Net/Waka.Lego/Properties/Resources.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego/Properties/Resources.Designer.cs


Fork.Net/Waka.Lego/Properties/Resources.resx → Fork.Net/Waka.Plugin/Waka.Lego/Properties/Resources.resx


Fork.Net/Waka.Lego/Properties/Settings.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego/Properties/Settings.Designer.cs


Fork.Net/Waka.Lego/Properties/Settings.settings → Fork.Net/Waka.Plugin/Waka.Lego/Properties/Settings.settings


Fork.Net/Waka.Lego/Properties/app.manifest → Fork.Net/Waka.Plugin/Waka.Lego/Properties/app.manifest


Fork.Net/Waka.Lego/Views/MainForm.Designer.cs → Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.Designer.cs


Fork.Net/Waka.Lego/Views/MainForm.cs → Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.cs


Fork.Net/Waka.Lego/Views/MainForm.resx → Fork.Net/Waka.Plugin/Waka.Lego/Views/MainForm.resx


Fork.Net/Waka.Lego/Waka.Lego.csproj → Fork.Net/Waka.Plugin/Waka.Lego/Waka.Lego.csproj


+ 31 - 1
Fork.Net/Y.Utils/DataUtils/EncryptUtils/AesTool.cs

@@ -13,7 +13,11 @@ namespace Y.Utils.DataUtils.EncryptUtils
 {
     public class AesTool
     {
-        //byte[] keyArray = UTF8Encoding.UTF8.GetBytes("12345678901234567890123456789012");
+        private static int AESKeyLength = 32;//AES加密的密码为32位
+        private static char AESFillChar = 'Y';//AES密码填充字符
+
+        public static string DefaultPassword = "yuzhengyang";//默认密码
+
         /// <summary>
         /// 加密
         /// </summary>
@@ -22,6 +26,7 @@ namespace Y.Utils.DataUtils.EncryptUtils
         /// <returns></returns>
         public static string Encrypt(string str, string key)
         {
+            key = FmtPassword(key);
             byte[] keyArray = Encoding.UTF8.GetBytes(key);
             byte[] toEncryptArray = Encoding.UTF8.GetBytes(str);
 
@@ -43,6 +48,7 @@ namespace Y.Utils.DataUtils.EncryptUtils
         /// <returns></returns>
         public static byte[] Encrypt(byte[] array, string key)
         {
+            key = FmtPassword(key);
             byte[] keyArray = Encoding.UTF8.GetBytes(key);
 
             RijndaelManaged rDel = new RijndaelManaged();
@@ -63,6 +69,7 @@ namespace Y.Utils.DataUtils.EncryptUtils
         /// <returns></returns>
         public static string Decrypt(string str, string key)
         {
+            key = FmtPassword(key);
             byte[] keyArray = UTF8Encoding.UTF8.GetBytes(key);
             byte[] toEncryptArray = Convert.FromBase64String(str);
 
@@ -84,6 +91,7 @@ namespace Y.Utils.DataUtils.EncryptUtils
         /// <returns></returns>
         public static byte[] Decrypt(byte[] array, string key)
         {
+            key = FmtPassword(key);
             byte[] keyArray = UTF8Encoding.UTF8.GetBytes(key);
 
             RijndaelManaged rDel = new RijndaelManaged();
@@ -96,5 +104,27 @@ namespace Y.Utils.DataUtils.EncryptUtils
 
             return resultArray;
         }
+        /// <summary>
+        /// 格式化密码
+        /// </summary>
+        /// <param name="s">要格式化的密码</param>
+        /// <returns></returns>
+        public static string FmtPassword(string s)
+        {
+            string password = s ?? "";
+
+            //格式化密码
+            if (password.Length < AESKeyLength)
+            {
+                //补足不够长的密码
+                password = password + new string(AESFillChar, AESKeyLength - password.Length);
+            }
+            else if (password.Length > AESKeyLength)
+            {
+                //截取过长的密码
+                password = password.Substring(0, AESKeyLength);
+            }
+            return password;
+        }
     }
 }

+ 106 - 160
Fork.Net/Y.Utils/IOUtils/FileUtils/FileEncryptTool.cs

@@ -9,10 +9,8 @@ namespace Y.Utils.IOUtils.FileUtils
 {
     public class FileEncryptTool
     {
-        private static int AESKeyLength = 32;//AES加密的密码为32位
-        private static char AESFillChar = 'Y';//AES密码填充字符
         private static string FileTypeDesc = "Oreo.FileMan.EncryptFile";
-        private static int FileHeadLength = 128;
+        private static int FileHeadLength = 256;
         private static int FileBuffer = 1024 * 1024;
 
         /// <summary>
@@ -21,99 +19,83 @@ namespace Y.Utils.IOUtils.FileUtils
         /// <param name="srcFile"></param>
         /// <param name="dstFile"></param>
         /// <param name="password"></param>
-        /// <returns></returns>
-        public static bool Encrypt(string srcFile, string dstFile, string password)
+        /// <returns>
+        /// 1:操作成功
+        /// -11:要加密的文件不存在
+        /// -12:加密后的目标文件已存在
+        /// -404:未知错误,操作失败
+        /// </returns>
+        public static int Encrypt(string srcFile, string dstFile, string password)
         {
-            string fmtPwd = FmtPassword(password);
-            string pwdMd5 = MD5Tool.Encrypt(fmtPwd);
-            //检测文件存在
-            if (File.Exists(srcFile) && !File.Exists(dstFile))
+            DateTime begin = DateTime.Now;
+            if (!File.Exists(srcFile)) return -11; //要加密的文件不存在
+            if (File.Exists(dstFile)) return -12;//加密后的目标文件已存在
+
+            string fmtPwd = AesTool.FmtPassword(password);
+            string pwdMd5 = MD5Tool.Encrypt(MD5Tool.Encrypt(fmtPwd));
+
+            string md5 = FileTool.GetMD5(srcFile);
+            using (FileStream fsRead = new FileStream(srcFile, FileMode.Open))
             {
-                string md5 = FileTool.GetMD5(srcFile);
-                using (FileStream fsRead = new FileStream(srcFile, FileMode.Open))
+                using (FileStream fsWrite = new FileStream(dstFile, FileMode.Create))
                 {
-                    using (FileStream fsWrite = new FileStream(dstFile, FileMode.Create))
+                    try
                     {
-                        try
-                        {
-                            //文件头部数据定义
-                            List<byte[]> headdata = new List<byte[]>()
+                        //文件头部数据定义
+                        List<byte[]> headdata = new List<byte[]>()
                             {
                                 Encoding.Default.GetBytes(FileTypeDesc),
                                 Encoding.Default.GetBytes(md5),
-                                Encoding.Default.GetBytes(fmtPwd),
-                                Encoding.Default.GetBytes(pwdMd5)
+                                Encoding.Default.GetBytes(AesTool.Encrypt(fmtPwd,AesTool.DefaultPassword)),
+                                Encoding.Default.GetBytes(pwdMd5),
+                                Encoding.Default.GetBytes(DateTime.Now.ToString())
                             };
-                            //写入长度
-                            for (int i = 0; i < FileHeadLength; i++)
+                        //写入长度
+                        for (int i = 0; i < FileHeadLength; i++)
+                        {
+                            if (headdata.Count > i)
                             {
-                                if (headdata.Count > i)
-                                {
-                                    byte[] length = BitConverter.GetBytes(headdata[i].Length);
-                                    fsWrite.Write(length, 0, length.Length);
-                                }
-                                else
-                                {
-                                    byte[] length = BitConverter.GetBytes(0);
-                                    fsWrite.Write(length, 0, length.Length);
-                                }
+                                byte[] length = BitConverter.GetBytes(headdata[i].Length);
+                                fsWrite.Write(length, 0, length.Length);
                             }
-                            //写入数据
-                            for (int i = 0; i < headdata.Count; i++)
+                            else
                             {
-                                fsWrite.Write(headdata[i], 0, headdata[i].Length);
+                                byte[] length = BitConverter.GetBytes(0);
+                                fsWrite.Write(length, 0, length.Length);
                             }
+                        }
+                        //写入数据
+                        for (int i = 0; i < headdata.Count; i++)
+                        {
+                            fsWrite.Write(headdata[i], 0, headdata[i].Length);
+                        }
 
-                            //设置文件头部信息
-                            //byte[] typeByte = Encoding.Default.GetBytes(FileTypeDesc);
-                            //byte[] md5Byte = Encoding.Default.GetBytes(md5);
-                            //byte[] pwdByte = Encoding.Default.GetBytes(fmtPwd);
-                            //byte[] pwdMd5Byte = Encoding.Default.GetBytes(pwdMd5);
-                            //设置文件头部数据长度信息
-                            //long[] headpart = new long[FileHeadLength];
-                            //headpart[0] = typeByte.Length;
-                            //headpart[1] = md5Byte.Length;
-                            //headpart[2] = pwdByte.Length;
-                            //headpart[3] = pwdMd5Byte.Length;
-                            //写入头部长度信息
-                            //foreach (var h in headpart)
-                            //{
-                            //    byte[] temp = BitConverter.GetBytes(h);
-                            //    fsWrite.Write(temp, 0, temp.Length);
-                            //}
-                            //写入文件头部信息
-                            //fsWrite.Write(typeByte, 0, typeByte.Length);
-                            //fsWrite.Write(md5Byte, 0, md5Byte.Length);
-                            //fsWrite.Write(pwdByte, 0, pwdByte.Length);
-                            //fsWrite.Write(pwdMd5Byte, 0, pwdMd5Byte.Length);
-
-                            //写入文件源数据
-                            int readCount = 0;
-                            byte[] buffer = new byte[FileBuffer];
-                            while ((readCount = fsRead.Read(buffer, 0, buffer.Length)) > 0)
+                        //写入文件源数据
+                        int readCount = 0;
+                        byte[] buffer = new byte[FileBuffer];
+                        while ((readCount = fsRead.Read(buffer, 0, buffer.Length)) > 0)
+                        {
+                            if (readCount != buffer.Length)
+                            {
+                                byte[] temp = new byte[readCount];
+                                Buffer.BlockCopy(buffer, 0, temp, 0, readCount);
+                                byte[] enbyte = AesTool.Encrypt(temp, fmtPwd);
+                                fsWrite.Write(enbyte, 0, enbyte.Length);
+                            }
+                            else
                             {
-                                if (readCount != buffer.Length)
-                                {
-                                    byte[] temp = new byte[readCount];
-                                    Buffer.BlockCopy(buffer, 0, temp, 0, readCount);
-                                    byte[] enbyte = AesTool.Encrypt(temp, fmtPwd);
-                                    fsWrite.Write(enbyte, 0, enbyte.Length);
-                                }
-                                else
-                                {
-                                    byte[] enbyte = AesTool.Encrypt(buffer, fmtPwd);
-                                    fsWrite.Write(enbyte, 0, enbyte.Length);
-                                }
+                                byte[] enbyte = AesTool.Encrypt(buffer, fmtPwd);
+                                fsWrite.Write(enbyte, 0, enbyte.Length);
                             }
-                            return true;
                         }
-                        catch { }
+                        return 1;//操作成功
                     }
+                    catch (Exception e) { }
                 }
                 //加密失败后,删除加密的文件
-                try { File.Delete(dstFile); } catch { }
+                try { File.Delete(dstFile); } catch (Exception e) { }
             }
-            return false;
+            return -404;//未知错误,操作失败
         }
         /// <summary>
         /// 文件解密
@@ -121,108 +103,72 @@ namespace Y.Utils.IOUtils.FileUtils
         /// <param name="srcFile"></param>
         /// <param name="dstFile"></param>
         /// <param name="password"></param>
-        /// <returns></returns>
-        public static bool Decrypt(string srcFile, string dstFile, string password)
+        /// <returns>
+        /// 1:操作成功
+        /// -11:要解密的文件不存在
+        /// -12:解密后的目标文件已存在
+        /// -90:解锁密码错误
+        /// -404:未知错误,操作失败
+        /// </returns>
+        public static int Decrypt(string srcFile, string dstFile, string password)
         {
-            string fmtPwd = FmtPassword(password);
-            string pwdMd5 = MD5Tool.Encrypt(fmtPwd);
-            //检测文件存在
-            if (File.Exists(srcFile) && !File.Exists(dstFile))
+            if (!File.Exists(srcFile)) return -11;//要解密的文件不存在
+            if (File.Exists(dstFile)) return -12;//解密后的目标文件已存在
+
+            string fmtPwd = AesTool.FmtPassword(password);
+            string pwdMd5 = MD5Tool.Encrypt(MD5Tool.Encrypt(fmtPwd));
+            List<string> headdata = new List<string>();
+            using (FileStream fsRead = new FileStream(srcFile, FileMode.Open))
             {
-                string[] fileInfo = new string[FileHeadLength];
-                using (FileStream fsRead = new FileStream(srcFile, FileMode.Open))
+                using (FileStream fsWrite = new FileStream(dstFile, FileMode.Create))
                 {
-                    using (FileStream fsWrite = new FileStream(dstFile, FileMode.Create))
+                    try
                     {
-                        try
+                        byte[] headlength = new byte[4 * FileHeadLength];
+                        if (fsRead.Read(headlength, 0, headlength.Length) == headlength.Length)
                         {
-                            List<byte[]> headdata = new List<byte[]>();
-                            for()
-
-                            byte[] headpart = new byte[8 * FileHeadLength];//fmk文件头
-                            long[] dataLong = new long[FileHeadLength];//信息长度
-                            if (fsRead.Read(headpart, 0, headpart.Length) == headpart.Length)
+                            for (int i = 0; i < FileHeadLength; i++)
                             {
-                                //读取信息长度
-                                for (int i = 0; i < dataLong.Length; i++)
-                                {
-                                    dataLong[i] = BitConverter.ToInt64(headpart, i * 8);
-                                }
-                                byte[] typeByte = new byte[dataLong[0]];
-                                byte[] md5Byte = new byte[dataLong[1]];
-                                byte[] pwdByte = new byte[dataLong[2]];
-                                byte[] pwdMd5Byte = new byte[dataLong[3]];
-
-                                fsRead.Read(typeByte, 0, typeByte.Length);
-                                fsRead.Read(md5Byte, 0, md5Byte.Length);
-                                fsRead.Read(pwdByte, 0, pwdByte.Length);
-                                fsRead.Read(pwdMd5Byte, 0, pwdMd5Byte.Length);
-
-                                fileInfo[0] = Encoding.Default.GetString(typeByte);
-                                fileInfo[1] = Encoding.Default.GetString(md5Byte);
-                                fileInfo[2] = Encoding.Default.GetString(pwdByte);
-                                fileInfo[3] = Encoding.Default.GetString(pwdMd5Byte);
+                                int datalong = BitConverter.ToInt32(headlength, i * 4);
+                                byte[] tempdata = new byte[datalong];
+                                fsRead.Read(tempdata, 0, datalong);
+                                headdata.Add(Encoding.Default.GetString(tempdata));
                             }
+                        }
+                        if (pwdMd5 != headdata[3]) return -90;//解锁密码错误
 
-                            if (pwdMd5 == fileInfo[3])
+                        int readCount = 0;
+                        byte[] buffer = new byte[FileBuffer + 16];
+                        while ((readCount = fsRead.Read(buffer, 0, buffer.Length)) > 0)
+                        {
+                            if (readCount != buffer.Length)
+                            {
+                                byte[] temp = new byte[readCount];
+                                Buffer.BlockCopy(buffer, 0, temp, 0, readCount);
+                                byte[] debyte = AesTool.Decrypt(temp, fmtPwd);
+                                fsWrite.Write(debyte, 0, debyte.Length);
+                            }
+                            else
                             {
-                                int readCount = 0;
-                                byte[] buffer = new byte[FileBuffer + 16];
-                                while ((readCount = fsRead.Read(buffer, 0, buffer.Length)) > 0)
-                                {
-                                    if (readCount != buffer.Length)
-                                    {
-                                        byte[] temp = new byte[readCount];
-                                        Buffer.BlockCopy(buffer, 0, temp, 0, readCount);
-                                        byte[] debyte = AesTool.Decrypt(temp, fmtPwd);
-                                        fsWrite.Write(debyte, 0, debyte.Length);
-                                    }
-                                    else
-                                    {
-                                        byte[] debyte = AesTool.Decrypt(buffer, fmtPwd);
-                                        fsWrite.Write(debyte, 0, debyte.Length);
-                                    }
-                                }
+                                byte[] debyte = AesTool.Decrypt(buffer, fmtPwd);
+                                fsWrite.Write(debyte, 0, debyte.Length);
                             }
                         }
-                        catch { }
                     }
-                }
-                string md5 = FileTool.GetMD5(dstFile);
-                if (md5 == fileInfo[1])
-                {
-                    return true;
-                }
-                else
-                {
-                    //解密失败后,删除解密的文件
-                    try { File.Delete(dstFile); } catch { }
+                    catch (Exception e) { }
                 }
             }
-            return false;
-        }
-
-        /// <summary>
-        /// 格式化密码
-        /// </summary>
-        /// <param name="s">要格式化的密码</param>
-        /// <returns></returns>
-        private static string FmtPassword(string s)
-        {
-            string password = s ?? "";
-
-            //格式化密码
-            if (password.Length < AESKeyLength)
+            string md5 = FileTool.GetMD5(dstFile);
+            if (md5 == headdata[1])
             {
-                //补足不够长的密码
-                password = password + new string(AESFillChar, AESKeyLength - password.Length);
+                return 1;//操作成功
             }
-            else if (password.Length > AESKeyLength)
+            else
             {
-                //截取过长的密码
-                password = password.Substring(0, AESKeyLength);
+                //解密失败后,删除解密的文件
+                try { File.Delete(dstFile); } catch (Exception e) { }
             }
-            return password;
+            return -404;//未知错误,操作失败
         }
     }
 }

+ 1 - 0
Fork.Net/Y.Utils/Y.Utils.csproj

@@ -22,6 +22,7 @@
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <Prefer32Bit>false</Prefer32Bit>
+    <DocumentationFile>bin\Debug\Y.Utils.XML</DocumentationFile>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>pdbonly</DebugType>