Exemple #1
0
        private void SendEncKeyVector(byte[] toEncrypt, PublicKey pk)
        {
            var             listToSend = ClientRsa.Encrypt(toEncrypt, pk.E, pk.N);
            BinaryFormatter bf         = new BinaryFormatter();
            MemoryStream    ms         = new MemoryStream();

            MessageLog("Отправляю ключ");
            SendCommand(toEncrypt.Length == 32 ? Commands.SendKey : Commands.SendVector);

            bf.Serialize(ms, listToSend);
            stream.Write(ms.ToArray(), 0, ms.ToArray().Length);
            MessageLog("Ключ отправлен");
        }
Exemple #2
0
        private void SendFileHash(PrivateKey pk)
        {
            MySha256 clientSha = new MySha256();
            var      hashValue = clientSha.computeHash(file);

            PrintByteArray(hashValue);

            var hash = ClientRsa.Encrypt(hashValue, pk.D, pk.N);

            BinaryFormatter bf = new BinaryFormatter();
            MemoryStream    ms = new MemoryStream();

            Console.WriteLine(Commands.SendHash);
            SendCommand(Commands.SendHash);
            bf.Serialize(ms, hash);
            stream.Write(ms.ToArray(), 0, ms.ToArray().Length);
            MessageLog("Хеш отправлен");
        }