mirror of https://github.com/ogoun/Zero.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
692 B
26 lines
692 B
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace ZeroLevel.Services.Utils
|
|
{
|
|
public static class RRandom
|
|
{
|
|
public static int RandomInteger(int min, int max)
|
|
{
|
|
uint scale = uint.MaxValue;
|
|
while (scale == uint.MaxValue)
|
|
{
|
|
byte[] four_bytes = new byte[4];
|
|
RandomNumberGenerator.Fill(four_bytes);
|
|
scale = BitConverter.ToUInt32(four_bytes, 0);
|
|
}
|
|
return (int)(min + (max - min) * (scale / (double)uint.MaxValue));
|
|
}
|
|
|
|
public static bool OverLimit(int limit)
|
|
{
|
|
return RandomInteger(0, 1000) > limit;
|
|
}
|
|
}
|
|
}
|