<?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%2FFile_Stream%2FFile_Cryptography</id>
		<title>Csharp/C Sharp/File Stream/File Cryptography - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FC_Sharp%2FFile_Stream%2FFile_Cryptography"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File_Cryptography&amp;action=history"/>
		<updated>2026-04-29T21:53:43Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File_Cryptography&amp;diff=1306&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/File_Stream/File_Cryptography&amp;diff=1306&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/File_Stream/File_Cryptography&amp;diff=1307&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/C_Sharp/File_Stream/File_Cryptography&amp;diff=1307&amp;oldid=prev"/>
				<updated>2010-05-26T11:45:37Z</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;==Illustrates asymmetric cryptography==&lt;br /&gt;
&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;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example19_11.cs illustrates asymmetric cryptography&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
public class Example19_11 &lt;br /&gt;
{&lt;br /&gt;
    public static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        // Create a new crypto provider&lt;br /&gt;
        RSACryptoServiceProvider rsa = &lt;br /&gt;
            new RSACryptoServiceProvider();&lt;br /&gt;
        // Data to encrypt&lt;br /&gt;
        Byte[] testData = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};&lt;br /&gt;
        // Encrypt the data&lt;br /&gt;
        Byte[] encryptedData = rsa.Encrypt(testData, false);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Encrypted data:&amp;quot;);&lt;br /&gt;
        for(int i=0; i&amp;lt;encryptedData.GetLength(0); i++)&lt;br /&gt;
        {&lt;br /&gt;
            Console.Write(&amp;quot;{0} &amp;quot;, encryptedData[i]);&lt;br /&gt;
        }&lt;br /&gt;
        Console.WriteLine();&lt;br /&gt;
        // Decrypt the data&lt;br /&gt;
        Byte[] decryptedData = rsa.Decrypt(encryptedData, false);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Decrypted Data:&amp;quot;);&lt;br /&gt;
        for(int i=0; i&amp;lt;decryptedData.GetLength(0); i++)&lt;br /&gt;
        {&lt;br /&gt;
            Console.Write(&amp;quot;{0} &amp;quot;, decryptedData[i]);&lt;br /&gt;
        }&lt;br /&gt;
        Console.WriteLine();&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;
==Illustrates declarative role-based security==&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;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
&lt;br /&gt;
/*&lt;br /&gt;
  Example19_8.cs illustrates declarative role-based security&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.Permissions;&lt;br /&gt;
[PrincipalPermissionAttribute(SecurityAction.Demand, Role=&amp;quot;Administrators&amp;quot;)]&lt;br /&gt;
public class Example19_8 &lt;br /&gt;
{&lt;br /&gt;
    public static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        // Create a new file to work with&lt;br /&gt;
        FileStream fsOut = File.Create(@&amp;quot;c:\\temp\\test.txt&amp;quot;);&lt;br /&gt;
        // Create a StreamWriter to handle writing&lt;br /&gt;
        StreamWriter sw = new StreamWriter(fsOut);&lt;br /&gt;
        // And write some data&lt;br /&gt;
        sw.WriteLine(&amp;quot;&amp;quot;Twas brillig, and the slithy toves&amp;quot;);&lt;br /&gt;
        sw.WriteLine(&amp;quot;Did gyre and gimble in the wabe.&amp;quot;);&lt;br /&gt;
        sw.Flush();&lt;br /&gt;
        sw.Close();&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;
==Illustrates decrypting a file==&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;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example19_10.cs illustrates decrypting a file&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
public class Example19_10 &lt;br /&gt;
{&lt;br /&gt;
    public static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        // Create a new crypto provider&lt;br /&gt;
        TripleDESCryptoServiceProvider tdes = &lt;br /&gt;
            new TripleDESCryptoServiceProvider();&lt;br /&gt;
        // open the file containing the key and IV&lt;br /&gt;
        FileStream fsKeyIn = File.OpenRead(@&amp;quot;c:\temp\encrypted.key&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        // use a BinaryReader to read formatted data from the file&lt;br /&gt;
        BinaryReader br = new BinaryReader(fsKeyIn);&lt;br /&gt;
        // read data from the file and close it&lt;br /&gt;
        tdes.Key = br.ReadBytes(24);&lt;br /&gt;
        tdes.IV = br.ReadBytes(8);&lt;br /&gt;
        // Open the encrypted file&lt;br /&gt;
        FileStream fsIn = File.OpenRead(@&amp;quot;c:\\temp\\encrypted.txt&amp;quot;);&lt;br /&gt;
        // Create a cryptostream to decrypt from the filestream&lt;br /&gt;
        CryptoStream cs = new CryptoStream(fsIn, tdes.CreateDecryptor(),&lt;br /&gt;
            CryptoStreamMode.Read);&lt;br /&gt;
        // Create a StreamReader to format the input&lt;br /&gt;
        StreamReader sr = new StreamReader(cs);&lt;br /&gt;
        // And decrypt the data&lt;br /&gt;
        Console.WriteLine(sr.ReadToEnd());&lt;br /&gt;
        sr.Close();&lt;br /&gt;
    }&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;
==Illustrates demanding permissions==&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;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example19_5.cs illustrates demanding permissions&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.Permissions;&lt;br /&gt;
[FileIOPermissionAttribute(SecurityAction.Demand,&lt;br /&gt;
All=@&amp;quot;c:\\temp&amp;quot;)]&lt;br /&gt;
public class Example19_5 &lt;br /&gt;
{&lt;br /&gt;
    public static void MakeFile() &lt;br /&gt;
    {&lt;br /&gt;
        // Create a new file to work with&lt;br /&gt;
        FileStream fsOut = File.Create(@&amp;quot;c:\\temp\\test.txt&amp;quot;);&lt;br /&gt;
        // Create a StreamWriter to handle writing&lt;br /&gt;
        StreamWriter sw = new StreamWriter(fsOut);&lt;br /&gt;
        // And write some data&lt;br /&gt;
        sw.WriteLine(&amp;quot;&amp;quot;Twas brillig, and the slithy toves&amp;quot;);&lt;br /&gt;
        sw.WriteLine(&amp;quot;Did gyre and gimble in the wabe.&amp;quot;);&lt;br /&gt;
        sw.Flush();&lt;br /&gt;
        sw.Close();&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;
==Illustrates encrypting a file==&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;
Mastering Visual C# .NET&lt;br /&gt;
by Jason Price, Mike Gunderloy&lt;br /&gt;
Publisher: Sybex;&lt;br /&gt;
ISBN: 0782129110&lt;br /&gt;
*/&lt;br /&gt;
/*&lt;br /&gt;
  Example19_9.cs illustrates encrypting a file&lt;br /&gt;
*/&lt;br /&gt;
using System;&lt;br /&gt;
using System.IO;&lt;br /&gt;
using System.Security.Cryptography;&lt;br /&gt;
public class Example19_9 &lt;br /&gt;
{&lt;br /&gt;
    public static void Main() &lt;br /&gt;
    {&lt;br /&gt;
        // Create a new file to work with&lt;br /&gt;
        FileStream fsOut = File.Create(@&amp;quot;c:\temp\encrypted.txt&amp;quot;);&lt;br /&gt;
        // Create a new crypto provider&lt;br /&gt;
        TripleDESCryptoServiceProvider tdes = &lt;br /&gt;
            new TripleDESCryptoServiceProvider();&lt;br /&gt;
        // Create a cryptostream to encrypt to the filestream&lt;br /&gt;
        CryptoStream cs = new CryptoStream(fsOut, tdes.CreateEncryptor(), &lt;br /&gt;
            CryptoStreamMode.Write);&lt;br /&gt;
        // Create a StreamWriter to format the output&lt;br /&gt;
        StreamWriter sw = new StreamWriter(cs);&lt;br /&gt;
        // And write some data&lt;br /&gt;
        sw.WriteLine(&amp;quot;&amp;quot;Twas brillig, and the slithy toves&amp;quot;);&lt;br /&gt;
        sw.WriteLine(&amp;quot;Did gyre and gimble in the wabe.&amp;quot;);&lt;br /&gt;
        sw.Flush();&lt;br /&gt;
        sw.Close();&lt;br /&gt;
        // save the key and IV for future use&lt;br /&gt;
        FileStream fsKeyOut = File.Create(@&amp;quot;c:\\temp\encrypted.key&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        // use a BinaryWriter to write formatted data to the file&lt;br /&gt;
        BinaryWriter bw = new BinaryWriter(fsKeyOut);&lt;br /&gt;
        // write data to the file&lt;br /&gt;
        bw.Write( tdes.Key );&lt;br /&gt;
        bw.Write( tdes.IV );&lt;br /&gt;
        // flush and close&lt;br /&gt;
        bw.Flush();&lt;br /&gt;
        bw.Close();&lt;br /&gt;
    }&lt;br /&gt;
}&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>