Csharp/C Sharp by API/System.Security.Cryptography/RandomNumberGenerator
Версия от 15:31, 26 мая 2010; (обсуждение)
RandomNumberGenerator.Create()
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));
}
}
RandomNumberGenerator.GetBytes
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));
}
}