Example #1
0
        public YueGeDencrypt2()
        {
            Dictionary <string, string> cache = null; // GetCache(Md5Key);

            Console.WriteLine("-----------------------------");
            Console.WriteLine("");

            string root = SystemConsole.GetInputStr("输入目标目录:");

            if (Directory.Exists(root))
            {
                var folder = Path.GetFileName(root);
                root += root.EndsWith("\\") ? "" : "\\";
                var files =
                    Directory.GetFiles(root, "*.*", SearchOption.AllDirectories)
                    .Select(p => p.Replace(root, "").Replace("\\", "/"))
                    .Where(p => Path.GetFileNameWithoutExtension(p).Length == 32)
                    .ToList();

                files.ForEach(file =>
                {
                    File.WriteAllBytes(file + ".temp", UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file)));
                });

                return;

                var dirRoot = root.Replace(folder, "");
                files.ForEach((file, i, count) =>
                {
                    var path    = folder + "/" + file;
                    var newPath = "";
                    if (cache.TryGetValue(path, out newPath))
                    {
                        var outPath = dirRoot + newPath;
                        FileHelper.CreateDirectory(outPath);
                        var p = ((float)i / count).ToString("P") + "\t" + path;
                        if (extensionList.Contains(Path.GetExtension(path)))
                        {
                            Console.WriteLine("路径解码中..." + p);
                            File.Copy(root + file, outPath, true);
                        }
                        else
                        {
                            Console.WriteLine("路径解码并文件解密中..." + p);
                            File.WriteAllBytes(outPath, UtilSecurity.DecryptionBytes(File.ReadAllBytes(root + file)));
                        }
                    }
                    else
                    {
                        Console.WriteLine("不存在的资源文件!");
                    }
                });
            }
        }
Example #2
0
        public static void UnMakeDecryptor(string path)
        {
            var bytes = File.ReadAllBytes(path);

            try
            {
                bytes = UtilSecurity.DecryptionBytes(bytes, UtilSecurity.MakeDecryptorTransform(Path.GetFileName(path)));
                FileHelper.CreateDirectory(path);
                File.WriteAllBytes(path, bytes);
            }
            catch (Exception)
            {
                throw;
            }
        }