<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FNetwork%2FCrypto_Connection</id>
		<title>Csharp/C Sharp/Network/Crypto Connection - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FNetwork%2FCrypto_Connection"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Crypto_Connection&amp;action=history"/>
		<updated>2026-04-29T21:21:51Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Crypto_Connection&amp;diff=1473&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Crypto_Connection&amp;diff=1473&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:19Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Crypto_Connection&amp;diff=1474&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/Network/Crypto_Connection&amp;diff=1474&amp;oldid=prev"/>
				<updated>2010-05-26T11:47:07Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Cryp Data Receiver==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Network Programming &lt;br /&gt;
by Richard Blum&lt;br /&gt;
Publisher: Sybex &lt;br /&gt;
ISBN: 0782141765&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Net;&lt;br /&gt;
using System.Net.Sockets;&lt;br /&gt;
using System.Runtime.Serialization;&lt;br /&gt;
using System.Runtime.Serialization.Formatters.Soap;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CryptoDataRcvr&lt;br /&gt;
{&lt;br /&gt;
   private SerialEmployee RecvData(NetworkStream strm)&lt;br /&gt;
   {&lt;br /&gt;
      MemoryStream memstrm = new MemoryStream();&lt;br /&gt;
      byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,&lt;br /&gt;
                    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,&lt;br /&gt;
                   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();&lt;br /&gt;
      CryptoStream csw = new CryptoStream(memstrm, tdes.CreateDecryptor(Key, IV),&lt;br /&gt;
                         CryptoStreamMode.Write);&lt;br /&gt;
      byte[] data = new byte[2048];&lt;br /&gt;
      int recv = strm.Read(data, 0, 4);&lt;br /&gt;
      int size = BitConverter.ToInt32(data, 0);&lt;br /&gt;
      int offset = 0;&lt;br /&gt;
      while(size &amp;gt; 0)&lt;br /&gt;
      {&lt;br /&gt;
         recv = strm.Read(data, 0, size);&lt;br /&gt;
         csw.Write(data, offset, recv);&lt;br /&gt;
         offset += recv;&lt;br /&gt;
         size -= recv;&lt;br /&gt;
      }&lt;br /&gt;
      csw.FlushFinalBlock();&lt;br /&gt;
      IFormatter formatter = new SoapFormatter();&lt;br /&gt;
      memstrm.Position = 0;&lt;br /&gt;
      SerialEmployee emp = (SerialEmployee)formatter.Deserialize(memstrm);&lt;br /&gt;
      memstrm.Close();&lt;br /&gt;
      return emp;&lt;br /&gt;
   }      &lt;br /&gt;
   public CryptoDataRcvr()&lt;br /&gt;
   {&lt;br /&gt;
      TcpListener server = new TcpListener(9050);&lt;br /&gt;
      server.Start();&lt;br /&gt;
      Console.WriteLine(&amp;quot;Waiting for a client...&amp;quot;);&lt;br /&gt;
      TcpClient client = server.AcceptTcpClient();&lt;br /&gt;
      NetworkStream strm = client.GetStream();&lt;br /&gt;
      SerialEmployee emp1 = RecvData(strm);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp1.EmployeeID = {0}&amp;quot;, emp1.EmployeeID);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp1.LastName = {0}&amp;quot;, emp1.LastName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp1.FirstName = {0}&amp;quot;, emp1.FirstName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp1.YearsService = {0}&amp;quot;, emp1.YearsService);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp1.Salary = {0}\n&amp;quot;, emp1.Salary);&lt;br /&gt;
      SerialEmployee emp2 = RecvData(strm);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp2.EmployeeID = {0}&amp;quot;, emp2.EmployeeID);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp2.LastName = {0}&amp;quot;, emp2.LastName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp2.FirstName = {0}&amp;quot;, emp2.FirstName);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp2.YearsService = {0}&amp;quot;, emp2.YearsService);&lt;br /&gt;
      Console.WriteLine(&amp;quot;emp2.Salary = {0}&amp;quot;, emp2.Salary);&lt;br /&gt;
      strm.Close();&lt;br /&gt;
      server.Stop();&lt;br /&gt;
   }&lt;br /&gt;
   public static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      CryptoDataRcvr cdr = new CryptoDataRcvr();&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
[Serializable]&lt;br /&gt;
public class SerialEmployee&lt;br /&gt;
{&lt;br /&gt;
   public int EmployeeID;&lt;br /&gt;
   public string LastName;&lt;br /&gt;
   public string FirstName;&lt;br /&gt;
   public int YearsService;&lt;br /&gt;
   public double Salary;&lt;br /&gt;
   public SerialEmployee()&lt;br /&gt;
   {&lt;br /&gt;
      EmployeeID = 0;&lt;br /&gt;
      LastName = null;&lt;br /&gt;
      FirstName = null;&lt;br /&gt;
      YearsService = 0;&lt;br /&gt;
      Salary = 0.0;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Cryp Data Sender==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Network Programming &lt;br /&gt;
by Richard Blum&lt;br /&gt;
Publisher: Sybex &lt;br /&gt;
ISBN: 0782141765&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Net;&lt;br /&gt;
using System.Net.Sockets;&lt;br /&gt;
using System.Runtime.Serialization;&lt;br /&gt;
using System.Runtime.Serialization.Formatters.Soap;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CryptoDataSender&lt;br /&gt;
{&lt;br /&gt;
   private void SendData(NetworkStream strm, SerialEmployee emp)&lt;br /&gt;
   {&lt;br /&gt;
      IFormatter formatter = new SoapFormatter();&lt;br /&gt;
      MemoryStream memstrm = new MemoryStream();&lt;br /&gt;
      byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();&lt;br /&gt;
      CryptoStream csw = new CryptoStream(memstrm, tdes.CreateEncryptor(Key, IV), CryptoStreamMode.Write);&lt;br /&gt;
      formatter.Serialize(csw, emp);&lt;br /&gt;
      csw.FlushFinalBlock();&lt;br /&gt;
      byte[] data = memstrm.GetBuffer();&lt;br /&gt;
      int memsize = (int)memstrm.Length;&lt;br /&gt;
      byte[] size = BitConverter.GetBytes(memsize);&lt;br /&gt;
      strm.Write(size, 0, 4);&lt;br /&gt;
      strm.Write(data, 0, (int)memsize);&lt;br /&gt;
      strm.Flush();&lt;br /&gt;
      csw.Close();&lt;br /&gt;
      memstrm.Close();&lt;br /&gt;
   }&lt;br /&gt;
   public CryptoDataSender()&lt;br /&gt;
   {&lt;br /&gt;
      SerialEmployee emp1 = new SerialEmployee();&lt;br /&gt;
      SerialEmployee emp2 = new SerialEmployee();&lt;br /&gt;
      emp1.EmployeeID = 1;&lt;br /&gt;
      emp1.LastName = &amp;quot;Blum&amp;quot;;&lt;br /&gt;
      emp1.FirstName = &amp;quot;Katie Jane&amp;quot;;&lt;br /&gt;
      emp1.YearsService = 12;&lt;br /&gt;
      emp1.Salary = 35000.50;&lt;br /&gt;
      emp2.EmployeeID = 2;&lt;br /&gt;
      emp2.LastName = &amp;quot;Blum&amp;quot;;&lt;br /&gt;
      emp2.FirstName = &amp;quot;Jessica&amp;quot;;&lt;br /&gt;
      emp2.YearsService = 9;&lt;br /&gt;
      emp2.Salary = 23700.30;&lt;br /&gt;
      TcpClient client = new TcpClient(&amp;quot;127.0.0.1&amp;quot;, 9050);&lt;br /&gt;
      NetworkStream strm = client.GetStream();&lt;br /&gt;
      SendData(strm, emp1);&lt;br /&gt;
      SendData(strm, emp2);&lt;br /&gt;
      strm.Close();&lt;br /&gt;
      client.Close();&lt;br /&gt;
   }&lt;br /&gt;
   public static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      CryptoDataSender cds = new CryptoDataSender();&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
[Serializable]&lt;br /&gt;
public class SerialEmployee&lt;br /&gt;
{&lt;br /&gt;
   public int EmployeeID;&lt;br /&gt;
   public string LastName;&lt;br /&gt;
   public string FirstName;&lt;br /&gt;
   public int YearsService;&lt;br /&gt;
   public double Salary;&lt;br /&gt;
   public SerialEmployee()&lt;br /&gt;
   {&lt;br /&gt;
      EmployeeID = 0;&lt;br /&gt;
      LastName = null;&lt;br /&gt;
      FirstName = null;&lt;br /&gt;
      YearsService = 0;&lt;br /&gt;
      Salary = 0.0;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==CryptoStream demo==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;&lt;br /&gt;
/*&lt;br /&gt;
C# Network Programming &lt;br /&gt;
by Richard Blum&lt;br /&gt;
Publisher: Sybex &lt;br /&gt;
ISBN: 0782141765&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
using System.Text;&lt;br /&gt;
public class CryptoTest&lt;br /&gt;
{&lt;br /&gt;
   public static void Main()&lt;br /&gt;
   {&lt;br /&gt;
      Console.Write(&amp;quot;Enter phrase to encrypt: &amp;quot;);&lt;br /&gt;
      string phrase = Console.ReadLine();&lt;br /&gt;
      MemoryStream memstrm = new MemoryStream();&lt;br /&gt;
      byte[] Key = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,&lt;br /&gt;
                    0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      byte[] IV = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,&lt;br /&gt;
                   0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16};&lt;br /&gt;
      TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();&lt;br /&gt;
      CryptoStream csw = new CryptoStream(memstrm,&lt;br /&gt;
                     tdes.CreateEncryptor(Key, IV), CryptoStreamMode.Write);&lt;br /&gt;
      csw.Write(Encoding.ASCII.GetBytes(phrase), 0, phrase.Length);&lt;br /&gt;
      csw.FlushFinalBlock();&lt;br /&gt;
      byte[] cryptdata = memstrm.GetBuffer();&lt;br /&gt;
      Console.WriteLine(&amp;quot;Encrypted: {0}&amp;quot;,&lt;br /&gt;
              Encoding.ASCII.GetString(cryptdata, 0, (int)memstrm.Length));&lt;br /&gt;
      memstrm.Position = 0;&lt;br /&gt;
      byte[] data = new byte[1024];&lt;br /&gt;
      CryptoStream csr = new CryptoStream(memstrm,&lt;br /&gt;
                     tdes.CreateDecryptor(Key, IV), CryptoStreamMode.Read);&lt;br /&gt;
      int recv = csr.Read(data, 0, data.Length);&lt;br /&gt;
      string newphrase = Encoding.ASCII.GetString(data, 0, recv);&lt;br /&gt;
      Console.WriteLine(&amp;quot;Decrypted: {0}&amp;quot;, newphrase);&lt;br /&gt;
      csr.Close();&lt;br /&gt;
      csw.Close();&lt;br /&gt;
      memstrm.Close();&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>