Example #1
0
        //Отправка сообщений
        private void SendMessage()
        {
            Socket socket = new Socket(IpServer.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            try
            {
                socket.Connect(IpServer, port);
                label4.Text  = "Подключение с сервером установлено";
                Send.Enabled = true;
                byte[] key            = Encoding.UTF8.GetBytes("Key");
                RC4    encoder        = new RC4(key);
                string message        = DateTime.Now.ToString("[HH:mm:ss]") + Login + ": " + richTextBox1.Text;
                byte[] encryptBytes   = Encoding.UTF8.GetBytes(message);
                byte[] result         = encoder.Encode(encryptBytes, encryptBytes.Length);
                int    SendMsg        = socket.Send(result);
                byte[] buffer         = new byte[1024];
                int    bytesRec       = socket.Receive(buffer);
                RC4    decoder        = new RC4(key);
                byte[] decryptedBytes = decoder.Decode(result, result.Length);
                string message1       = Encoding.UTF8.GetString(decryptedBytes);
                richTextBox2.Text = richTextBox2.Text + message1 + "\r\n";
                using (var sw = File.AppendText(@"Log_chat.txt"))
                {
                    sw.WriteLine(message + "\r\n");
                }
                richTextBox1.Clear();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void DeCipher(string outputFile)
        {
            byte[] bytes = File.ReadAllBytes(outputFile);

            RC4 decoder = new RC4(key);

            byte[] result = decoder.Decode(bytes, bytes.Length);

            File.WriteAllBytes(outputFile, result);
        }
Example #3
0
 public static byte[] RC4_Decrypt_Method(byte[] raw_resource)
 {
     byte[] decoded = null;
     for (int i = 0; i < Helper.RC4keys.Count; i++)
     {
         RC4 rc4 = new RC4(Encoding.ASCII.GetBytes(Helper.RC4keys[i]));
         decoded = rc4.Decode(raw_resource, raw_resource.Length);
         if (decoded.Take(2).SequenceEqual(valid_gzip))
         {
             decoded = gzip_decompress(decoded);
             return(decoded);
         }
         else
         {
             return(decoded);
         }
     }
     return(null);
 }
Example #4
0
        public void loadSeparatedAssets(string projectPath, bool locked)
        {
            _projectPath = projectPath;

            Assets.items.Clear();

            string[] packs = Directory.GetFiles(Path.Combine(projectPath), "*.pak");

            for (int i = 0; i < packs.Length; i++)
            {
                AssetList list = new AssetList();

                if (locked)
                {
                    byte[] key = ByteConverter.GetBytes("dfy3hfi3789y478yhge7y578yrhgiudhr8967498u839udhkjghjk");
                    RC4 rc4 = new RC4(key);

                    byte[] file = File.ReadAllBytes(packs[i]);
                    file = rc4.Decode(file, file.Length);

                    MemoryStream ms = new MemoryStream();
                    ms.Write(file, 0, file.Length);
                    ms.Seek(0, SeekOrigin.Begin);

                    list = (AssetList)Serialization.deserialize(ms);

                    ms.Dispose();
                }
                else
                {
                    list = (AssetList)Serialization.deserialize(packs[i]);
                }

                for (int j = 0; j < list.Count; j++)
                {
                    Assets.items.Add(list[j]);
                }
            }

            if (Assets.items.Count > 0)
                setReferences();
        }