RNGCryptoServiceProvider を使用して System.Random から継承して数値を取得できますが、かなりの数のメソッドをオーバーライドする必要があるため、注意が必要です。
/*
[MSDN]
Notes to Inheritors:
In the .NET Framework versions 1.0 and 1.1, a minimum implementation of
a class derived from Random required overriding the Sample method
to define a new or modified algorithm for generating random numbers.
The derived class could then rely on the base class implementation
of the Random.Next(), Random.Next(Int32), Random.Next(Int32, Int32),
NextBytes, and NextDouble methods to call the derived class implementation of the Sample method.
In the .NET Framework version 2.0 and later, the behavior of the Random.Next(),
Random.Next(Int32, Int32), and NextBytes methods have changed
so that these methods do not necessarily call the derived class implementation
of the Sample method.
As a result, classes derived from Random that target the .NET Framework 2.0
and later should also override these three methods.
*/
class CryptoRandom : System.Random {
private RandomNumberGenerator rng;
public CryptoRandom() {
rng = new RNGCryptoServiceProvider();
}
public override int Next() {
byte[] bytes = new byte[4];
rng.GetBytes(bytes);
return int.MaxValue & BitConverter.ToInt32(bytes, 0);
}
public override void NextBytes(byte[] b)
{
rng.GetBytes(b);
}
public override int Next(int lo, int hi){
throw new Exception("TODO override (arc4random_uniform is beautiful)");
}
protected override double Sample()
{
throw new Exception("TODO override");
}
}
または、これをすべて使用して小さな (長さ <=255) 文字列にインデックスを取得するため、バイトを直接使用してインデックスを取得することができます (モジュロ バイアスを回避するため、この回答を書きました最初に -- http://BXR.SU/OpenBSD/lib/libc/crypt/arc4random_uniform.c#arc4random_uniformの arc4random_uniform を参照してください)。