예제 #1
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);
        }
예제 #2
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;
            }
        }
        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 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);
        }
예제 #6
0
        public static void Main(string[] args)
        {
#if DEBUG
            var workspace = @"D:\yunding\assets";
#else
            var commandLineArgs = Environment.GetCommandLineArgs();
            var workspace       = Path.GetDirectoryName(commandLineArgs[0]);
#endif

            var files = Directory.GetFiles(workspace, "*.png", SearchOption.AllDirectories);

            foreach (var path in files)
            {
                var bytes = File.ReadAllBytes(path);

                bytes = bytes.Skip("YD0888ResPackage".Length).ToArray();

                bytes = XXTEA.Decrypt(bytes, "G9w0BAQefAa0888M");

                if (bytes == null)
                {
                    continue;
                }

                File.WriteAllBytes(path, bytes);
            }
        }
예제 #7
0
 private Byte[] DecryptString(Byte[] data, Byte level)
 {
     if (encryptMode >= level)
     {
         data = XXTEA.Decrypt(data, key);
     }
     return(data);
 }
예제 #8
0
 private Byte[] Decrypt(Byte[] data, Byte level, Byte encryptMode)
 {
     if (key != null && encryptMode >= level)
     {
         data = XXTEA.Decrypt(data, key);
     }
     return(data);
 }
        //Decryption file
        public IActionResult DecryptionFile(IFormFile File, string key)
        {
            fileclass        op  = new fileclass();
            Decryption_Class op2 = new Decryption_Class();

            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 = op2.BinaryToString(op2.convert_DNA_to_binary(op2.convert_finalDNA_to_DNA(op2.split_DNA(line))));
                op.Decryptfile = XXTEA.Decrypt(str, key);
            }
            downloadtext = op.Decryptfile;
            //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, "Decryptmessage.txt")))
            {
                outputFile.Write(downloadtext);
            }

            return(View("DecryptionFile", op));
        }
예제 #10
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);
        }
예제 #11
0
        protected override IScsMessage DeserializeMessage(byte[] bytes)
        {
            if (encrypt)
            {
                bytes = XXTEA.Decrypt(bytes, keys);
            }
            if (compress)
            {
                bytes = CompressionManager.DecompressGZip(bytes);
            }

            return(base.DeserializeMessage(bytes));
        }
예제 #12
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();
        }
예제 #14
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);
        }
예제 #15
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);
            }
        }
예제 #16
0
 internal static byte[] Decrypt(byte[] data, byte[] validateKey, byte[] encryptKey, HashAlgorithm hashAlgorithm, int hashReultLength)
 {
     try {
         var input = XXTEA.Decrypt(data, encryptKey);
         var hash  = new byte[hashReultLength];
         Buffer.BlockCopy(input, input.Length - hashReultLength, hash, 0, hashReultLength);
         using (var stream = new MemoryStream()) {
             stream.Write(input, 0, input.Length - hashReultLength);
             var length = stream.Length;
             stream.Write(validateKey, 0, validateKey.Length);
             var validating = hashAlgorithm.ComputeHash(stream.ToArray());
             if (BitEquals(hash, validating))
             {
                 stream.Position = 0;
                 stream.SetLength(length);
                 return(stream.ToArray());
             }
         }
     } catch { }
     return(null);
 }
예제 #17
0
파일: LoginPage.xaml.cs 프로젝트: wpmyj/LC
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            string        strErrorMsg = string.Empty;
            AppConfigs    ac          = new AppConfigs();
            List <string> user_list   = ac.getAppSettingsByKey("user");

            foreach (string name in user_list)
            {
                cmb_loginName.Items.Add(name);
            }
            if (cmb_loginName.Items.Count > 0)
            {
                cmb_loginName.SelectedIndex = 0;
                List <string> pass_list = ac.getAppSettingsByKey(cmb_loginName.Text);
                if (pass_list.Count > 0)
                {
                    //有密码信息,增解密并设置
                    System.Text.Encoding encoder = System.Text.Encoding.UTF8;
                    try
                    {
                        pwdPassword.Password         = encoder.GetString(XXTEA.Decrypt(System.Convert.FromBase64String(pass_list[0]), encoder.GetBytes("1234567890abcdef")));
                        chb_remberPassword.IsChecked = true;
                    }
                    catch (Exception)
                    {
                        //AisinoMessageBox.Show("记录密码读取错误", "提示", MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        //AisinoMessageBox.Show("记录密码读取错误", UIResources.MsgInfo, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
                        strErrorMsg = "记录密码读取错误";
                    }
                    if (strErrorMsg != string.Empty)
                    {
                        await DialogManager.ShowMessageAsync(Application.Current.MainWindow as MetroWindow, UIResources.MsgInfo, strErrorMsg, MessageDialogStyle.Affirmative, null);
                    }
                }
            }
            cmb_loginName.Focus();
        }
예제 #18
0
        public static MemoryStream DeompressAndDecryptLZMA(byte[] memory, string password)
        {
            MemoryStream output = new MemoryStream();

            Decoder coder = new Decoder();

            byte[] decryptedBytes = string.IsNullOrEmpty(password) ? memory : XXTEA.Decrypt(memory, 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, memory.Length, fileLength, null);
                    }
                }
            }
            return(output);
        }
예제 #19
0
        static void Main(string[] args)
        {
            var key = "DhbUnJeJ3s6NcLtSvR1TJuVt891zaWXFZQvtM7b2sJHvCxp9noZ2fck";

            var bytes = File.ReadAllBytes("ui_com_bk_card_boss1.png");

            if (Encoding.UTF8.GetString(bytes.Take(6).ToArray()) != EncryptMagicNumber)
            {
                Console.WriteLine("this file is not encrypted");
                return;
            }
            bytes = bytes.Skip(6).ToArray();

            var decrypt_data = XXTEA.Decrypt(bytes, key);

            if (decrypt_data != null)
            {
                File.WriteAllBytes("out.png", decrypt_data);
            }
            else
            {
                Console.WriteLine("failed");
            }
        }
예제 #20
0
        public void Run(byte clientId, string key)
        {
            UdpClient socket = new UdpClient(4020);

            socket.JoinMulticastGroup(IPAddress.Parse("239.255.77.88"));
            IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);

            while (true)
            {
                Byte[] message = socket.Receive(ref RemoteIpEndPoint);

                using (BinaryReader reader = new BinaryReader(new MemoryStream(message))) {
                    byte client = reader.ReadByte();
                    if (client != clientId)
                    {
                        continue;
                    }

                    byte   enc   = reader.ReadByte();
                    ushort type  = 0;
                    ushort code  = 0;
                    int    value = 0;

                    if (enc > 0)
                    {
                        Byte[]       encrypted = reader.ReadBytes(enc);
                        Byte[]       decrypted = XXTEA.Decrypt(encrypted, key);
                        BinaryReader encreader = new BinaryReader(new MemoryStream(decrypted));
                        UInt32       rnd       = encreader.ReadUInt32();
                        type  = encreader.ReadUInt16();
                        code  = encreader.ReadUInt16();
                        value = encreader.ReadInt32();
                        encreader.Close();
                    }
                    else if (enc == 0)
                    {
                        UInt32 rnd = reader.ReadUInt32();
                        type  = reader.ReadUInt16();
                        code  = reader.ReadUInt16();
                        value = reader.ReadInt32();
                    }

                    reader.Close();

                    //Console.WriteLine("Type:" + type + " Code:" + code + " Value:" + value);
                    //continue;

                    if (type == (uint)LinuxEventTypes.EV_SYN)
                    {
                        // We only handle SYN_REPORT
                        if (code == (uint)LinuxSynCodes.SYN_REPORT)
                        {
                            // Send buffered inputs
                            SendStackedInputs();
                        }
                    }
                    else if (type == (uint)LinuxEventTypes.EV_KEY)
                    {
                        if (code >= (uint)UsefulConst.BTN_MIN && code <= (uint)UsefulConst.BTN_MAX)
                        {
                            // Mouse Buttons

                            if (value == 2)
                            {
                                continue;               // Don't send repeats
                            }
                            if (code == (uint)UsefulConst.BTN_LEFT)
                            {
                                StackMouseInput(0, 0, 0, value > 0 ? (uint)MouseEventFlags.MOUSEEVENTF_LEFTDOWN
                                                               : (uint)MouseEventFlags.MOUSEEVENTF_LEFTUP);
                            }
                            else if (code == (uint)UsefulConst.BTN_RIGHT)
                            {
                                StackMouseInput(0, 0, 0, value > 0 ? (uint)MouseEventFlags.MOUSEEVENTF_RIGHTDOWN
                                                               : (uint)MouseEventFlags.MOUSEEVENTF_RIGHTUP);
                            }
                            else if (code == (uint)UsefulConst.BTN_MIDDLE)
                            {
                                StackMouseInput(0, 0, 0, value > 0 ? (uint)MouseEventFlags.MOUSEEVENTF_MIDDLEDOWN
                                                               : (uint)MouseEventFlags.MOUSEEVENTF_MIDDLEUP);
                            }
                            else if (code == (uint)UsefulConst.BTN_SIDE)
                            {
                                StackMouseInput(0, 0, 1, value > 0 ? (uint)MouseEventFlags.MOUSEEVENTF_XDOWN
                                                               : (uint)MouseEventFlags.MOUSEEVENTF_XUP);
                            }
                            else if (code == (uint)UsefulConst.BTN_EXTRA)
                            {
                                StackMouseInput(0, 0, 2, value > 0 ? (uint)MouseEventFlags.MOUSEEVENTF_XDOWN
                                                               : (uint)MouseEventFlags.MOUSEEVENTF_XUP);
                            }
                        }
                        else
                        {
                            // Keyboard key
                            if (LinuxKeyCode2Virtual.ContainsKey(code))
                            {
                                // Must use wVk mechanism instead of raw scancode
                                StackKbdInput(LinuxKeyCode2Virtual[code], 0, (uint)(value > 0 ? 0x0 : 0x2));
                            }
                            else if (LinuxKeyCode2Extended.ContainsKey(code))
                            {
                                // Extended key
                                StackKbdInput(0, 0xe0, 0);
                                StackKbdInput(0, LinuxKeyCode2Extended[code], (uint)(value > 0 ? 0x9 : 0xb));
                            }
                            else
                            {
                                // Raw scancode
                                StackKbdInput(0, code, (uint)(value > 0 ? 0x8 : 0xa));
                            }
                        }
                    }
                    else if (type == (uint)LinuxEventTypes.EV_REL)
                    {
                        if (code == (uint)UsefulConst.REL_X)
                        {
                            StackMouseInput(value, 0, 0, (uint)MouseEventFlags.MOUSEEVENTF_MOVE);
                        }
                        else if (code == (uint)UsefulConst.REL_Y)
                        {
                            StackMouseInput(0, value, 0, (uint)MouseEventFlags.MOUSEEVENTF_MOVE);
                        }
                        else if (code == (uint)UsefulConst.REL_WHEEL)
                        {
                            StackMouseInput(0, 0, value * 120, (uint)MouseEventFlags.MOUSEEVENTF_WHEEL);
                        }
                        else if (code == (uint)UsefulConst.REL_HWHEEL)
                        {
                            StackMouseInput(0, 0, value * 120, (uint)MouseEventFlags.MOUSEEVENTF_HWHEEL);
                        }
                    }
                }
            }
        }
예제 #21
0
 static byte[] XXTEADecrypt(byte[] Data, byte[] Key)
 {
     return(XXTEA.Decrypt(Data, Key));
 }
예제 #22
0
        /// <summary>
        /// Computes and shows the crypto results.
        /// </summary>
        private void TestAllAlgorithms()
        {
            /**
             * Input length is 17 chars but 19 bytes.
             */
            String input = "Hello to € World!";

            /**
             * Arrays for padding testing.
             */
            Byte[] pb = new Byte[12] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
            };
            Byte[] nb = new Byte[12] {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
            };

            /**
             * Test PKCS#7 padding.
             */
            Byte[] pp = PKCS7.Pad(pb, 8);
            Byte[] pu = PKCS7.Unpad(pp);
            //
            this.outputBox.Text += "PKCS#7 padded: " + BytesToString(pp) + "\n";
            this.outputBox.Text += "PKCS#7 unpadded: " + BytesToString(pu) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test zero byte padding.
             */
            Byte[] np = ZEROS.Pad(nb, 8);
            Byte[] nu = ZEROS.Unpad(np);
            //
            this.outputBox.Text += "Zero byte padded: " + BytesToString(np) + "\n";
            this.outputBox.Text += "Zero byte unpadded: " + BytesToString(nu) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Text to bytes conversion from input.
             */
            Byte[] utf8Bytes = Encoding.UTF8.GetBytes(input);
            Byte[] ubeBytes  = Encoding.BigEndianUnicode.GetBytes(input);
            Byte[] uleBytes  = Encoding.Unicode.GetBytes(input);
            //
            this.outputBox.Text += "UTF-16 BE bytes: " + BytesToString(ubeBytes) + "\n";
            this.outputBox.Text += "UTF-16 LE bytes: " + BytesToString(uleBytes) + "\n";
            this.outputBox.Text += "UTF-8 bytes: " + BytesToString(utf8Bytes) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test base16 encoding.
             */
            String b16e = Base16.Encode(utf8Bytes);

            Byte[] b16d = Base16.Decode(b16e);
            //
            this.outputBox.Text += "Base16 encoded in UTF-8: " + b16e + "\n";
            this.outputBox.Text += "Base16 decoded in UTF-8: " + Encoding.UTF8.GetString(b16d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test base64 encoding.
             */
            String b64e = Base64.Encode(utf8Bytes);

            Byte[] b64d = Base64.Decode(b64e);
            //
            this.outputBox.Text += "Base64 encoded in UTF-8: " + b64e + "\n";
            this.outputBox.Text += "Base64 decoded in UTF-8: " + Encoding.UTF8.GetString(b64d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test generating GUID's.
             */
            String guid1 = GUID.Create();
            String guid2 = GUID.Create();
            String guid3 = GUID.Create();

            //
            this.outputBox.Text += "Generated GUID 1: " + guid1 + "\n";
            this.outputBox.Text += "Generated GUID 2: " + guid2 + "\n";
            this.outputBox.Text += "Generated GUID 3: " + guid3 + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test ROT13 encoding.
             */
            Byte[] r13e = ROT13.Encode(utf8Bytes);
            Byte[] r13d = ROT13.Decode(r13e);
            //
            this.outputBox.Text += "ROT13 encrypted in UTF-8: " + Encoding.UTF8.GetString(r13e) + "\n";
            this.outputBox.Text += "ROT13 decrypted in UTF-8: " + Encoding.UTF8.GetString(r13d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test MD5 with one official test vector and custom input.
             * Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
             */
            Byte[] md5tv   = MD5.Compute(new Byte[0]);
            Byte[] md5utf8 = MD5.Compute(utf8Bytes);
            Byte[] md5key  = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] md5hmac = MD5.ComputeHMAC(md5key, utf8Bytes);
            //
            this.outputBox.Text += "MD5 from otv is ok: " + (Base16.Encode(md5tv) == "d41d8cd98f00b204e9800998ecf8427e").ToString() + "\n";
            this.outputBox.Text += "MD5 HMAC in UTF-8: " + Base16.Encode(md5hmac) + "\n";
            this.outputBox.Text += "MD5 in UTF-8: " + Base16.Encode(md5utf8) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test RIPEMD-160 with one official test vector and custom input.
             * Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
             */
            Byte[] rmd160tv   = RMD160.Compute(new Byte[0]);
            Byte[] rmd160utf8 = RMD160.Compute(utf8Bytes);
            Byte[] rmd160key  = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] rmd160hmac = RMD160.ComputeHMAC(rmd160key, utf8Bytes);
            //
            this.outputBox.Text += "RIPEMD-160 from otv is ok: " + (Base16.Encode(rmd160tv) == "9c1185a5c5e9fc54612808977ee8f548b2258d31").ToString() + "\n";
            this.outputBox.Text += "RIPEMD-160 HMAC in UTF-8: " + Base16.Encode(rmd160hmac) + "\n";
            this.outputBox.Text += "RIPEMD-160 in UTF-8: " + Base16.Encode(rmd160utf8) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test SHA-1 with one official test vector and custom input.
             * Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
             */
            Byte[] sha1tv   = SHA1.Compute(new Byte[0]);
            Byte[] sha1utf8 = SHA1.Compute(utf8Bytes);
            Byte[] sha1key  = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] sha1hmac = SHA1.ComputeHMAC(sha1key, utf8Bytes);
            //
            this.outputBox.Text += "SHA-1 from otv is ok: " + (Base16.Encode(sha1tv) == "da39a3ee5e6b4b0d3255bfef95601890afd80709").ToString() + "\n";
            this.outputBox.Text += "SHA-1 HMAC in UTF-8: " + Base16.Encode(sha1hmac) + "\n";
            this.outputBox.Text += "SHA-1 in UTF-8: " + Base16.Encode(sha1utf8) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test SHA-256 with one official test vector and custom input.
             * Vectors from: http://www.febooti.com/products/filetweak/members/hash-and-crc/test-vectors/
             */
            Byte[] sha256tv   = SHA256.Compute(new Byte[0]);
            Byte[] sha256utf8 = SHA256.Compute(utf8Bytes);
            Byte[] sha256key  = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] sha256hmac = SHA256.ComputeHMAC(sha256key, utf8Bytes);
            //
            this.outputBox.Text += "SHA-256 from otv is ok: " + (Base16.Encode(sha256tv) == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855").ToString() + "\n";
            this.outputBox.Text += "SHA-256 HMAC in UTF-8: " + Base16.Encode(sha256hmac) + "\n";
            this.outputBox.Text += "SHA-256 in UTF-8: " + Base16.Encode(sha256utf8) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test ARC4 with one official test vector and custom input.
             * Vectors from: http://reikon.us/arc4
             */
            Byte[] arc4tvk = Base16.Decode("0123456789abcdef");
            Byte[] arc4tvt = Base16.Decode("0123456789abcdef");
            Byte[] arc4tve = ARC4.Encrypt(arc4tvk, arc4tvt);
            Byte[] arc4tvd = ARC4.Decrypt(arc4tvk, arc4tve);
            //
            Byte[] arc4k = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] arc4e = ARC4.Encrypt(arc4k, utf8Bytes);
            Byte[] arc4d = ARC4.Decrypt(arc4k, arc4e);
            //
            this.outputBox.Text += "ARC4 otv encrypted is ok: " + (Base16.Encode(arc4tve) == "75b7878099e0c596") + "\n";
            this.outputBox.Text += "ARC4 otv decrypted is ok: " + (Base16.Encode(arc4tvd) == "0123456789abcdef") + "\n";
            this.outputBox.Text += "ARC4 encrypted in UTF-8: " + Base16.Encode(arc4e) + "\n";
            this.outputBox.Text += "ARC4 decrypted in UTF-8: " + Encoding.UTF8.GetString(arc4d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test XXTEA with one official test vector and custom input.
             * Vectors from: http://www.crypt.co.za/post/27
             */
            Byte[] xxttvk = Base16.Decode("9e3779b99b9773e9b979379e6b695156");
            Byte[] xxttvt = Base16.Decode("0102040810204080fffefcf8f0e0c080");
            Byte[] xxttve = XXTEA.Encrypt(xxttvk, xxttvt);
            Byte[] xxttvd = XXTEA.Decrypt(xxttvk, xxttve);
            //
            Byte[] xxteak = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] xxteae = XXTEA.Encrypt(xxteak, PKCS7.Pad(utf8Bytes, 4));
            Byte[] xxtead = PKCS7.Unpad(XXTEA.Decrypt(xxteak, xxteae));
            //
            this.outputBox.Text += "XXTEA otv encrypted is ok: " + (Base16.Encode(xxttve) == "01b815fd2e4894d13555da434c9d868a") + "\n";
            this.outputBox.Text += "XXTEA otv decrypted is ok: " + (Base16.Encode(xxttvd) == "0102040810204080fffefcf8f0e0c080") + "\n";
            this.outputBox.Text += "XXTEA encrypted in UTF-8: " + Base16.Encode(xxteae) + "\n";
            this.outputBox.Text += "XXTEA decrypted in UTF-8: " + Encoding.UTF8.GetString(xxtead) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test AES-128 with one official test vector and custom input.
             * Vectors from: http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
             */
            Byte[] aes128tvk = new Byte[16] {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
            };
            Byte[] aes128tvt = new Byte[16] {
                0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
            };
            Byte[] aes128tve = AES.Encrypt(aes128tvk, aes128tvt, OperationMode.ECB, null); // No padding needed.
            Byte[] aes128tvd = AES.Decrypt(aes128tvk, aes128tve, OperationMode.ECB, null); // No padding needed.
            //
            Byte[] aes128k = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] aes128e = AES.Encrypt(aes128k, PKCS7.Pad(utf8Bytes, 16), OperationMode.ECB, null);
            Byte[] aes128d = PKCS7.Unpad(AES.Decrypt(aes128k, aes128e, OperationMode.ECB, null));
            //
            this.outputBox.Text += "AES-128 otv encrypted is ok: " + (Base16.Encode(aes128tve) == "69c4e0d86a7b0430d8cdb78070b4c55a") + "\n";
            this.outputBox.Text += "AES-128 otv decrypted is ok: " + (Base16.Encode(aes128tvd) == "00112233445566778899aabbccddeeff") + "\n";
            this.outputBox.Text += "AES-128 (ECB mode) encrypted in UTF-8: " + Base16.Encode(aes128e) + "\n";
            this.outputBox.Text += "AES-128 (ECB mode) decrypted in UTF-8: " + Encoding.UTF8.GetString(aes128d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test AES-192 with one official test vector and custom input.
             * Vectors from: http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
             */
            Byte[] aes192tvk = new Byte[24] {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17
            };
            Byte[] aes192tvt = new Byte[16] {
                0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
            };
            Byte[] aes192tve = AES.Encrypt(aes192tvk, aes192tvt, OperationMode.ECB, null); // No padding needed.
            Byte[] aes192tvd = AES.Decrypt(aes192tvk, aes192tve, OperationMode.ECB, null); // No padding needed.
            //
            Byte[] aes192i = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] aes192k = Encoding.UTF8.GetBytes("123456789012345678901234");
            Byte[] aes192e = AES.Encrypt(aes192k, PKCS7.Pad(utf8Bytes, 16), OperationMode.CBC, aes192i);
            Byte[] aes192d = PKCS7.Unpad(AES.Decrypt(aes192k, aes192e, OperationMode.CBC, aes192i));
            //
            this.outputBox.Text += "AES-192 otv encrypted is ok: " + (Base16.Encode(aes192tve) == "dda97ca4864cdfe06eaf70a0ec0d7191") + "\n";
            this.outputBox.Text += "AES-192 otv decrypted is ok: " + (Base16.Encode(aes192tvd) == "00112233445566778899aabbccddeeff") + "\n";
            this.outputBox.Text += "AES-192 (CBC mode) encrypted in UTF-8: " + Base16.Encode(aes192e) + "\n";
            this.outputBox.Text += "AES-192 (CBC mode) decrypted in UTF-8: " + Encoding.UTF8.GetString(aes192d) + "\n";
            this.outputBox.Text += "\n";

            /**
             * Test AES-256 with one official test vector and custom input.
             * Vectors from: http://www.csrc.nist.gov/publications/fips/fips197/fips-197.pdf
             */
            Byte[] aes256tvk = new Byte[32] {
                0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f
            };
            Byte[] aes256tvt = new Byte[16] {
                0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
            };
            Byte[] aes256tve = AES.Encrypt(aes256tvk, aes256tvt, OperationMode.ECB, null); // No padding needed.
            Byte[] aes256tvd = AES.Decrypt(aes256tvk, aes256tve, OperationMode.ECB, null); // No padding needed.
            //
            Byte[] aes256i = Encoding.UTF8.GetBytes("1234567890123456");
            Byte[] aes256k = Encoding.UTF8.GetBytes("12345678901234561234567890123456");
            Byte[] aes256e = AES.Encrypt(aes256k, PKCS7.Pad(utf8Bytes, 16), OperationMode.CBC, aes256i);
            Byte[] aes256d = PKCS7.Unpad(AES.Decrypt(aes256k, aes256e, OperationMode.CBC, aes256i));
            //
            this.outputBox.Text += "AES-256 otv encrypted is ok: " + (Base16.Encode(aes256tve) == "8ea2b7ca516745bfeafc49904b496089") + "\n";
            this.outputBox.Text += "AES-256 otv decrypted is ok: " + (Base16.Encode(aes256tvd) == "00112233445566778899aabbccddeeff") + "\n";
            this.outputBox.Text += "AES-256 (CBC mode) encrypted in UTF-8: " + Base16.Encode(aes256e) + "\n";
            this.outputBox.Text += "AES-256 (CBC mode) decrypted in UTF-8: " + Encoding.UTF8.GetString(aes256d) + "\n";
            this.outputBox.Text += "\n";
        }