27 lines
681 B
C#
27 lines
681 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Chrosey.Extensions
|
|
{
|
|
internal class RandomSecureVersion
|
|
{
|
|
private readonly RNGCryptoServiceProvider _rngProvider = new RNGCryptoServiceProvider();
|
|
|
|
public int Next()
|
|
{
|
|
byte[] data = new byte[4];
|
|
this._rngProvider.GetBytes(data);
|
|
return BitConverter.ToInt32(data, 0);
|
|
}
|
|
|
|
public int Next(int maximumValue)
|
|
{
|
|
return this.Next(0, maximumValue);
|
|
}
|
|
|
|
public int Next(int minimumValue, int maximumValue)
|
|
{
|
|
return new Random(this.Next()).Next(minimumValue, maximumValue);
|
|
}
|
|
}
|
|
} |