Csharp/C Sharp by API/System.Security.Cryptography/RandomNumberGenerator — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 15:10, 26 мая 2010

RandomNumberGenerator.Create()

<source lang="csharp"> using System; using System.Security.Cryptography; class MainClass {

   public static void Main() {
       byte[] number = new byte[32];
       RandomNumberGenerator rng = RandomNumberGenerator.Create();
       rng.GetBytes(number);
       Console.WriteLine(BitConverter.ToString(number));
   }

}


 </source>


RandomNumberGenerator.GetBytes

<source lang="csharp"> using System; using System.Security.Cryptography; class MainClass {

   public static void Main() {
       byte[] number = new byte[32];
       RandomNumberGenerator rng = RandomNumberGenerator.Create();
       rng.GetBytes(number);
       Console.WriteLine(BitConverter.ToString(number));
   }

}


 </source>