Csharp/C Sharp by API/System.Security.Cryptography/RandomNumberGenerator — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
Admin (обсуждение | вклад) м (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>