示例#1
0
        private void CryptoClientForm_Load(object sender, EventArgs e)
        {
            // add algoritams in drop down
            ToolStripMenuItem menu = new ToolStripMenuItem("Algorithams");

            ToolStripMenuItem item = new ToolStripMenuItem("Substitution");
            ICryptoLibrary    alg  = new SimpleSubstitution();

            item.Tag       = alg;
            this.algorithm = alg;
            menu.DropDownItems.Add(item);

            alg      = new XXTEA();
            item     = new ToolStripMenuItem("XXTEA");
            item.Tag = alg;
            menu.DropDownItems.Add(item);

            alg      = new SHA2();
            item     = new ToolStripMenuItem("SHA2");
            item.Tag = alg;
            menu.DropDownItems.Add(item);
            // TODO: add Knapsack

            menu.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.OnClickedItem);
            this.msOptions.Items.Add(menu);


            this.Init();
        }
示例#2
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            var sd = openFileDialog1.ShowDialog();

            if (sd == DialogResult.OK)
            {
                String key = "1234567890";
                using (var fs = openFileDialog1.OpenFile())
                {
                    byte[] buffer = new byte[fs.Length];
                    fs.Read(buffer, 0, buffer.Length);
                    var    data  = XXTEA.Encrypt(buffer, key);
                    var    file  = new FileInfo(openFileDialog1.FileName);
                    string fname = Path.Combine(file.DirectoryName,
                                                Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + "_secure" +
                                                Path.GetExtension(openFileDialog1.FileName));
                    if (File.Exists(fname))
                    {
                        File.Delete(fname);
                    }
                    using (var fs2 = File.Create(fname))
                    {
                        fs2.Write(data, 0, data.Length);
                    }
                }
            }
        }
        public IActionResult DecryptionText(string cryptomsg, string key)
        {
            myclass          op  = new myclass();
            Decryption_Class op2 = new Decryption_Class();


            string str = op2.BinaryToString(op2.convert_DNA_to_binary(op2.convert_finalDNA_to_DNA(op2.split_DNA(cryptomsg))));

            op.orignalmsg = XXTEA.Decrypt(str, key);
            //decryption
            // op.cryptomsg = XXTEA.Decrypt(orignalmsg, key);
            string document = op.orignalmsg;
            //decryption
            // op.cryptomsg = XXTEA.Decrypt(orignalmsg, key);
            //create file or put Encrypt message in file
            //path which file put in
            string path_Root = _hosting.WebRootPath;
            string docPath   = path_Root + "\\files\\";

            // Write the specified text asynchronously to a new file named "WriteTextAsync.txt".
            using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, "Decryptmessage.txt")))
            {
                outputFile.Write(document);
            }

            return(View("DecryptionText", op));
        }
示例#4
0
    static void Decode()
    {
        string url   = Application.dataPath + "/txt-encode.bytes";
        var    bytes = XXTEA.Decrypt(File.ReadAllBytes(url));

        File.WriteAllBytes(url.Replace("txt-encode.bytes", "txt-decode.txt"), bytes);
    }
示例#5
0
        static void DeLua()
        {
            var file = File.ReadAllBytes(@"C:\__temp\Idle Knife_1.0.17\assets\Scripts\VersionID.lua");
            var data = Copy(file, 4);

            byte[] keys = { 0x4A, 0x89, 0xF1, 0xF1,
                            0xFB, 0xB2, 0x46, 0x23,
                            0xC2, 0x1C,    7, 0x8E,
                            0xF6, 0xEC, 0xCD, 0xF9 };

            byte[] keys2 =
            {
                0x24, 0x54, 0x26, 0x89,
                0xA8, 0x1C, 0x9C, 0xA6,
                0xD1, 0x50, 0x17,  0xB,
                0x5B, 0x6C,    5, 0xF6
            };

            var newdata = XXTEA.Decrypt(data, keys2);

            File.WriteAllBytes("1.lua", newdata);

            //newdata = CopyLua(newdata);

            //var newdata2 = XXTEA.Decrypt(newdata, keys);


            // File.WriteAllBytes("1.lua", newdata2);
        }
示例#6
0
        public static StorageMetadata CreateStorageFile(Stream dataStream, uint archiveNumber, ulong?profileKey)
        {
            StorageMetadata metadata = new StorageMetadata();

            metadata.ArchiveNumber = archiveNumber + 2;

            byte[] data = null;
            using (BinaryReader reader = new BinaryReader(dataStream))
            {
                data = reader.ReadBytes((int)reader.BaseStream.Length);
            }

            Array.Resize(ref data, data.Length + 1); // 1 byte null padding

            // Generate Spooky hash of data for later
            SpookyHash sh = new SpookyHash(0x155af93ac304200, 0x8ac7230489e7ffff);

            sh.Update(new SHA256Managed().ComputeHash(data));
            sh.Update(data);
            sh.Final(out metadata.Key[0], out metadata.Key[1]);

            var compressedData = Compress(data);
            var key            = GenerateKey(metadata, profileKey, true);

            metadata.StorageRaw       = XXTEA.Encrypt(compressedData, key);
            metadata.CompressedSize   = (uint)compressedData.Length;
            metadata.DecompressedSize = (uint)data.Length;

            return(metadata);
        }
示例#7
0
    public static void luajitEncode(string path)
    {
        string basePath = Application.dataPath;

        path = path.Replace("Assets/", "/");
        string dir     = Path.GetDirectoryName(path);
        string fname   = Path.GetFileNameWithoutExtension(path);
        string fext    = Path.GetExtension(path);
        string outPath = basePath + dir + "/" + fname + fext;

        outPath = outPath.Replace("/upgradeRes4Dev", "/upgradeRes4Publish");
        Directory.CreateDirectory(Path.GetDirectoryName(outPath));
                #if UNITY_IOS
        byte[] bytes = XXTEA.Encrypt(File.ReadAllBytes(basePath + path), XXTEA.defaultKey);
        File.WriteAllBytes(outPath, bytes);
                #elif UNITY_ANDROID
        //		string exeName = "/usr/local/bin/luajit";
        string exeName = "/usr/local/bin/luajit-2.0.4";
        //		string exeName = "/usr/local/bin/luajit-2.0.3";
        //		string exeName = "/usr/local/bin/luajit-2.1.0-alpha";
        if (!File.Exists(exeName))
        {
            UnityEngine.Debug.LogError("Ecode lua failed. file not fou" + exeName);
            return;
        }
        string arguments = "-b " + basePath + path + " " + outPath;
        Process.Start(exeName, arguments);
        //#else
        //		byte[] bytes = XXTEA.Encrypt(File.ReadAllBytes(basePath + path), XXTEA.defaultKey);
        //		File.WriteAllBytes(outPath, bytes);
                #endif
    }
示例#8
0
        static void DeIni()
        {
            var file = File.ReadAllBytes(@"C:\Users\liubo\Nox_share\App\LegionData");
            var data = Copy(file, 0);

            byte[] keys = { 0x4A, 0x89, 0xF1, 0xF1,
                            0xFB, 0xB2, 0x46, 0x23,
                            0xC2, 0x1C,    7, 0x8E,
                            0xF6, 0xEC, 0xCD, 0xF9 };

            byte[] keys2 =
            {
                0x24, 0x54, 0x26, 0x89,
                0xA8, 0x1C, 0x9C, 0xA6,
                0xD1, 0x50, 0x17,  0xB,
                0x5B, 0x6C,    5, 0xF6
            };

            var newdata = XXTEA.Decrypt(data, keys);

            File.WriteAllBytes("2.ini", newdata);

            //newdata = CopyLua(newdata);

            //var newdata2 = XXTEA.Decrypt(newdata, keys);


            // File.WriteAllBytes("1.lua", newdata2);
        }
示例#9
0
        private static void ParseStorageFile(StorageMetadata metadata, Stream storageStream, ulong?profileKey = null)
        {
            byte[] data = null;
            using (BinaryReader reader = new BinaryReader(storageStream))
            {
                data = reader.ReadBytes((int)reader.BaseStream.Length);
            }

            var rawSha256 = new SHA256Managed().ComputeHash(data);
            var sha256    = BitConverter.ToString(rawSha256).Replace("-", "");

            if (sha256 != metadata.SHA256)
            {
                throw new InvalidDataException("Invalid storage file. Corrupt or wrong file?");
            }

            if (metadata.StorageVersion == STORAGE_VERSION_V1)
            {
                var key           = GenerateKey(metadata, profileKey);
                var decryptedData = XXTEA.Decrypt(data, key);
                var output        = Decompress(metadata, decryptedData);

                // Verify data
                SpookyHash sh = new SpookyHash(0x155af93ac304200, 0x8ac7230489e7ffff);
                sh.Update(new SHA256Managed().ComputeHash(output));
                sh.Update(output);

                ulong hash1, hash2;
                sh.Final(out hash1, out hash2);

                ulong orig_hash1 = metadata.Key[0];
                ulong orig_hash2 = metadata.Key[1];

                if (orig_hash1 != hash1 || orig_hash2 != hash2)
                {
                    throw new InvalidDataException("Invalid decrypted data. Wrong key?");
                }

                metadata.StorageRaw = output;
            }
            else
            {
                SpookyHash sh = new SpookyHash(0x155af93ac304200, 0x8ac7230489e7ffff);
                sh.Update(rawSha256);
                sh.Update(data);

                ulong hash1, hash2;
                sh.Final(out hash1, out hash2);

                ulong orig_hash1 = metadata.Key[0];
                ulong orig_hash2 = metadata.Key[1];

                if (orig_hash1 != hash1 || orig_hash2 != hash2)
                {
                    throw new InvalidDataException("Invalid decrypted data. Wrong key?");
                }

                metadata.StorageRaw = data;
            }
        }
示例#10
0
 private Byte[] DecryptString(Byte[] data, Byte level)
 {
     if (encryptMode >= level)
     {
         data = XXTEA.Decrypt(data, key);
     }
     return(data);
 }
示例#11
0
        internal static byte[] RsaEncryptBase(MemoryStream stream, RSACryptoServiceProvider rsa, byte[] encryptKey, HashAlgorithm hashAlgorithm)
        {
            var signData = rsa.SignData(stream.ToArray(), hashAlgorithm);

            stream.Write(signData, 0, signData.Length);
            stream.WriteByte(Convert.ToByte(signData.Length));
            return(XXTEA.Encrypt(stream.ToArray(), encryptKey));
        }
示例#12
0
 private Byte[] Decrypt(Byte[] data, Byte level, Byte encryptMode)
 {
     if (key != null && encryptMode >= level)
     {
         data = XXTEA.Decrypt(data, key);
     }
     return(data);
 }
示例#13
0
 public static void Main (string[] args) {
     String str = "Hello World! 你好,中国!";
     String key = "1234567890";
     String encrypt_data = XXTEA.EncryptToBase64String(str, key);
     Console.WriteLine(encrypt_data);
     Debug.Assert("QncB1C0rHQoZ1eRiPM4dsZtRi9pNrp7sqvX76cFXvrrIHXL6" == encrypt_data);
     String decrypt_data = XXTEA.DecryptBase64StringToString(encrypt_data, key);
     Debug.Assert(str == decrypt_data);
 }
示例#14
0
        private void CryptoClientForm_Load(object sender, EventArgs e)
        {
            this.tbSrcPath.Text = ".\\" + this.defaultSrcPath;
            this.tbDstPath.Text = ".\\" + this.defaultDstPath;
            this.defaultSrcPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + this.defaultSrcPath;
            this.defaultDstPath = AppDomain.CurrentDomain.BaseDirectory.ToString() + this.defaultDstPath;

            string[] srcDicFiles = Directory.GetFiles(this.defaultSrcPath);

            foreach (string f in srcDicFiles)
            {
                this.lbFilesToEncrypt.Items.Add(f);
            }

            string[] dstDicFiles = Directory.GetFiles(this.defaultDstPath);

            foreach (string f in dstDicFiles)
            {
                this.lbEncryptedFiles.Items.Add(f);
            }

            this.CreateNewFileWatcher();


            ICryptoLibrary[] algorithams = new ICryptoLibrary[4];
            algorithams[0] = new SimpleSubstitution();
            algorithams[1] = new XXTEA();
            algorithams[2] = new SHA2();
            algorithams[3] = new Knapsack();

            specs = new Dictionary <string, byte[]>();

            // add algoritams in drop down
            ToolStripMenuItem menu = new ToolStripMenuItem("Algorithams");
            ToolStripMenuItem item;

            for (int i = 0; i < algorithams.Length; i++)
            {
                item     = new ToolStripMenuItem(algorithams[i].ToString());
                item.Tag = algorithams[i];
                menu.DropDownItems.Add(item);
                if (i == 0)
                {
                    this.algoritham = algorithams[i];
                }
            }

            menu.DropDownItemClicked += new System.Windows.Forms.ToolStripItemClickedEventHandler(this.OnClickedItem);
            this.msOptions.Items.Add(menu);

            this.Init();
            tbN.KeyPress  += this.tbKey_KeyPress;
            tbM.KeyPress  += this.tbKey_KeyPress;
            tbIM.KeyPress += this.tbKey_KeyPress;
            lbHint.Visible = false;
        }
示例#15
0
 private void makeExportFile(Stream s, string data)
 {
     byte[] buff = Encoding.UTF8.GetBytes(data);
     byte[] md5  = Helper.GetMD5(buff);
     buff = XXTEA.Encrypt(buff, KEY_CODE);
     s.Write(FILE_MARK, 0, FILE_MARK.Length);
     s.Write(md5, 0, md5.Length);
     s.Write(buff, 0, buff.Length);
     s.Close();
 }
        public IActionResult Indexfile(IFormFile File, string key)

        {
            fileclass  op  = new fileclass();
            Encryption op2 = new Encryption();

            if (File == null || File.Length == 0)
            {
                return(Content("file not selected"));
            }
            //get path
            string path_Root     = _hosting.WebRootPath;
            string path_to_files = path_Root + "\\files\\" + File.FileName;

            //copyfiles
            using (var stream = new FileStream(path_to_files, FileMode.Create))
            {
                File.CopyTo(stream);
            }



            // read file
            FileStream fileStream = new FileStream(path_to_files, FileMode.Open);

            using (StreamReader reader = new StreamReader(fileStream))
            {
                // string line = reader.ReadLine();
                string line = reader.ReadToEnd();
                //  op.Encryptfile = line;
                string str = XXTEA.Encrypt(line, key);
                op.Encryptfile = op2.convert_to_RNA(op2.convert_to_dna(op2.split_binary(op2.StringToBinary(str))));
            }
            downloadtext = op.Encryptfile;
            //delete file
            FileInfo fi = new FileInfo(path_to_files);

            if (fi != null)
            {
                System.IO.File.Delete(path_to_files);
                fi.Delete();
            }
            ///////////////////
            //create file or put Encrypt message in file
            //path which file put in
            string docPath = path_Root + "\\files\\";

            // Write the specified text asynchronously to a new file named "WriteTextAsync.txt".
            using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, "Encryptmessage.txt")))
            {
                outputFile.Write(downloadtext);
            }

            return(View("Indexfile", op));
        }
示例#17
0
        internal static byte[] Encrypt(MemoryStream stream, byte[] validateKey, byte[] encryptKey, HashAlgorithm hashAlgorithm)
        {
            var length = stream.Length;

            stream.Write(validateKey, 0, validateKey.Length);
            var hash = hashAlgorithm.ComputeHash(stream.ToArray());

            stream.SetLength(length);
            stream.Write(hash, 0, hash.Length);
            return(XXTEA.Encrypt(stream.ToArray(), encryptKey));
        }
示例#18
0
        internal static byte[] RsaDecryptBase(byte[] data, RSACryptoServiceProvider rsa, byte[] encryptKey, HashAlgorithm hashAlgorithm)
        {
            var input      = XXTEA.Decrypt(data, encryptKey);
            var hashLength = input[input.Length - 1];
            var hashData   = new byte[hashLength];
            var signData   = new byte[input.Length - hashLength - 1];

            Buffer.BlockCopy(input, input.Length - hashLength - 1, hashData, 0, hashLength);
            Buffer.BlockCopy(input, 0, signData, 0, signData.Length);
            return(rsa.VerifyData(signData, hashAlgorithm, hashData) ? signData : null);
        }
示例#19
0
 internal static byte[] Encrypt(byte[] data, byte[] validateKey, byte[] encryptKey, HashAlgorithm hashAlgorithm)
 {
     using (var stream = new MemoryStream()) {
         var length = data.Length;
         stream.Write(data, 0, length);
         stream.Write(validateKey, 0, validateKey.Length);
         var hash = hashAlgorithm.ComputeHash(stream.ToArray());
         stream.SetLength(length);
         stream.Write(hash, 0, hash.Length);
         return(XXTEA.Encrypt(stream.ToArray(), encryptKey));
     }
 }
示例#20
0
        protected override IScsMessage DeserializeMessage(byte[] bytes)
        {
            if (encrypt)
            {
                bytes = XXTEA.Decrypt(bytes, keys);
            }
            if (compress)
            {
                bytes = CompressionManager.DecompressGZip(bytes);
            }

            return(base.DeserializeMessage(bytes));
        }
示例#21
0
    public static void xxteaEncode(string path)
    {
        string basePath = Application.dataPath;

        path = path.Replace("Assets/", "/");
        string dir     = Path.GetDirectoryName(path);
        string fname   = Path.GetFileNameWithoutExtension(path);
        string fext    = Path.GetExtension(path);
        string outPath = basePath + dir + "/" + fname + fext;

        outPath = outPath.Replace("/upgradeRes4Dev", "/upgradeRes4Publish");
        Directory.CreateDirectory(Path.GetDirectoryName(outPath));
        byte[] bytes = XXTEA.Encrypt(System.Text.Encoding.UTF8.GetBytes(File.ReadAllText(basePath + path)), XXTEA.defaultKey);
        File.WriteAllBytes(outPath, bytes);
    }
示例#22
0
        protected override byte[] SerializeMessage(IScsMessage message)
        {
            var bytes = base.SerializeMessage(message);

            if (compress)
            {
                bytes = CompressionManager.CompressGZip(bytes);
            }
            if (encrypt)
            {
                bytes = XXTEA.Encrypt(bytes, keys);
            }

            return(bytes);
        }
示例#23
0
 private void SendOutput()
 {
     if (encryptMode >= 3)
     {
         buffer.Append("phprpc_output=\"");
         buffer.Append(EncodeString(XXTEA.Encrypt(encoding.GetBytes(output), key)));
         buffer.Append("\";\r\n");
     }
     else
     {
         buffer.Append("phprpc_output=\"");
         buffer.Append(EncodeString(output));
         buffer.Append("\";\r\n");
     }
 }
示例#24
0
            private void SolveLoginPuzzle(uint[] v, uint[] k, byte unknown)
            {
                for (uint guess = 0; guess < uint.MaxValue; guess++)
                {
                    k[3] = guess;
                    uint[] vClone = (uint[])v.Clone();
                    XXTEA.Encrypt(vClone, k, 6);
                    uint solution = vClone[1];

                    if (solution >> (32 - unknown) == 0 && (solution & (0x80000000 >> unknown)) != 0)
                    {
                        return;
                    }
                }
                throw new Exception("Failed to solve login puzzle");
            }
示例#25
0
        MemoryStream DeompressAndDecryptLZMA(string path, bool fromResourcesPath = false)
        {
            MemoryStream output = new MemoryStream();

            byte[]    inputBytes     = null;
            TextAsset objInResources = null;

            if (fromResourcesPath)
            {
                objInResources = Resources.Load(path, typeof(TextAsset)) as TextAsset;
                if (objInResources == null)
                {
                    return(null);
                }
                inputBytes = objInResources.bytes;
            }
            else
            {
                inputBytes = File.ReadAllBytes(path);
            }
            Decoder coder = new Decoder();

            byte[] decryptedBytes = string.IsNullOrEmpty(password) ? inputBytes : XXTEA.Decrypt(inputBytes, password);
            using (MemoryStream mem = new MemoryStream())
            {
                using (BinaryWriter binWriter = new BinaryWriter(mem))
                {
                    binWriter.Write(decryptedBytes);
                    mem.Position = 0;
                    using (BinaryReader binReader = new BinaryReader(mem))
                    {
                        byte[] properties = new byte[5];
                        binReader.Read(properties, 0, 5);
                        byte[] fileLengthBytes = new byte[8];
                        binReader.Read(fileLengthBytes, 0, 8);
                        long fileLength = BitConverter.ToInt64(fileLengthBytes, 0);
                        coder.SetDecoderProperties(properties);
                        coder.Code(mem, output, inputBytes.Length, fileLength, null);
                    }
                }
            }
            if (objInResources != null)
            {
                Resources.UnloadAsset(objInResources);
            }
            return(output);
        }
        static void TeaTest()
        {
            var    key       = Encoding.UTF8.GetBytes("288A339E65244CC995154A686C651B1E");
            var    encrypted = XXTEA.Encrypt(key, Encoding.UTF8.GetBytes(original));
            string roundtrip = Encoding.UTF8.GetString(XXTEA.Decrypt(key, encrypted));
            string hex       = Epic.Converters.HexString.Encode(encrypted);
            string base64    = Convert.ToBase64String(encrypted);

            //Display the original data and the decrypted data.
            Console.WriteLine($"Tea:");
            Console.WriteLine("Key:   {0}", key.Length);
            Console.WriteLine("Byte:   {0}", encrypted.Length);
            Console.WriteLine("Hex:   {0}, {1}", hex.Length, hex);
            Console.WriteLine("Base64:   {0}, {1}", base64.Length, base64);
            Console.WriteLine("Decode: {0}", roundtrip);
            Console.WriteLine();
        }
示例#27
0
        private void SaveLogonName(string loginName)
        {
            AppConfigs ac = new AppConfigs();

            //如果在appconfig中还不存在该用户,则保存该用户登陆名
            if (!ac.valueExistInAppSettings(loginName))
            {
                ac.addAppSettings("user", loginName);
                //如果选择了记住密码,则保存对应密码
                if (chb_remberPassword.IsChecked.Value)
                {
                    System.Text.Encoding encoder = System.Text.Encoding.UTF8;
                    Byte[] data     = XXTEA.Encrypt(encoder.GetBytes(pwdPassword.Password), encoder.GetBytes("1234567890abcdef"));
                    string password = System.Convert.ToBase64String(data);
                    ac.addAppSettings(loginName, password);
                }
            }
            //如果该用户已经存在,则判断是否选择保存密码
            else
            {
                if (chb_remberPassword.IsChecked.Value)
                {
                    //如果保存密码,则察看该用户密码是否已经存在,如果不存在则保存密码
                    System.Text.Encoding encoder = System.Text.Encoding.UTF8;
                    Byte[] data     = XXTEA.Encrypt(encoder.GetBytes(pwdPassword.Password), encoder.GetBytes("1234567890abcdef"));
                    string password = System.Convert.ToBase64String(data);
                    if (!ac.keyExistInAppSettings(loginName))
                    {
                        ac.addAppSettings(loginName, password);
                    }
                    else
                    {
                        ac.updateAppSettings(loginName, password);
                    }
                }
                else
                {
                    //如果不保存密码,则察看该用户密码是否已经存在,如果存在则删除该密码
                    if (ac.keyExistInAppSettings(loginName))
                    {
                        ac.delAppSettings(loginName);
                    }
                }
            }
        }
示例#28
0
        static void DePngs()
        {
            var files = Directory.GetFiles(@"C:\__temp\Idle Knife_1.0.17\assets", "*.png", SearchOption.AllDirectories);

            foreach (var file in files)
            {
                Console.WriteLine(file);
                var filedata = File.ReadAllBytes(file);

                if (filedata[0] == 'K' && filedata[1] == 'I' && filedata[2] == 'N' && filedata[3] == 'G')
                {
                }
                else
                {
                    Console.WriteLine("        此文件已被解密");
                    continue;
                }

                var data = Copy(filedata, 4);

                byte[] keys2 =
                {
                    0x24, 0x54, 0x26, 0x89,
                    0xA8, 0x1C, 0x9C, 0xA6,
                    0xD1, 0x50, 0x17,  0xB,
                    0x5B, 0x6C,    5, 0xF6
                };

                var newdata = XXTEA.Decrypt(data, keys2);
                try
                {
                    //newdata = CopyPng2(newdata);
                    newdata = UnZip(newdata);
                }
                catch (Exception)
                {
                    Console.WriteLine("此文件解码错误。");
                }

                File.WriteAllBytes(file + ".bak", filedata);
                File.WriteAllBytes(file, newdata);
            }
        }
示例#29
0
        static void DePng()
        {
            var file = File.ReadAllBytes(@"C:\__temp\Idle Knife_1.0.17\assets\GameScene\BulletStreak.png");
            var data = Copy(file, 4);

            byte[] keys2 =
            {
                0x24, 0x54, 0x26, 0x89,
                0xA8, 0x1C, 0x9C, 0xA6,
                0xD1, 0x50, 0x17,  0xB,
                0x5B, 0x6C,    5, 0xF6
            };

            var newdata = XXTEA.Decrypt(data, keys2);

            newdata = CopyPng(newdata);
            // newdata = Copy(newdata, 7 * 16 - 1);
            File.WriteAllBytes("1.png", newdata);
        }
示例#30
0
 public void CompressAndEncryptLZMA(string inputPath, string outputPath)
 {
     using (MemoryStream inputStream = new MemoryStream(File.ReadAllBytes(inputPath)))
     {
         Encoder coder = new Encoder();
         using (MemoryStream compressStream = new MemoryStream())
         {
             coder.WriteCoderProperties(compressStream);
             compressStream.Write(BitConverter.GetBytes(inputStream.Length), 0, 8);
             coder.Code(inputStream, compressStream, inputStream.Length, -1, null);
             if (string.IsNullOrEmpty(Config.password))
             {
                 File.WriteAllBytes(outputPath, compressStream.ToArray());
             }
             else
             {
                 File.WriteAllBytes(outputPath, XXTEA.Encrypt(compressStream.ToArray(), Config.password));
             }
         }
     }
 }