2022-08-30 15:00:58 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
|
|
|
|
|
namespace SharpChat {
|
|
|
|
|
public static class RNG {
|
2023-02-07 15:01:56 +00:00
|
|
|
|
private static Random NormalRandom { get; } = new();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
private static RandomNumberGenerator SecureRandom { get; } = RandomNumberGenerator.Create();
|
|
|
|
|
|
|
|
|
|
public static int Next() {
|
2023-02-10 06:07:59 +00:00
|
|
|
|
return NormalRandom.Next();
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int Next(int max) {
|
2023-02-10 06:07:59 +00:00
|
|
|
|
return NormalRandom.Next(max);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int Next(int min, int max) {
|
2023-02-10 06:07:59 +00:00
|
|
|
|
return NormalRandom.Next(min, max);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void NextBytes(byte[] buffer) {
|
2023-02-10 06:07:59 +00:00
|
|
|
|
SecureRandom.GetBytes(buffer);
|
2022-08-30 15:00:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|