25 lines
676 B
C#
25 lines
676 B
C#
using System;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace SharpChat {
|
|
public static class RNG {
|
|
private static Random NormalRandom { get; } = new();
|
|
private static RandomNumberGenerator SecureRandom { get; } = RandomNumberGenerator.Create();
|
|
|
|
public static int Next() {
|
|
return NormalRandom.Next();
|
|
}
|
|
|
|
public static int Next(int max) {
|
|
return NormalRandom.Next(max);
|
|
}
|
|
|
|
public static int Next(int min, int max) {
|
|
return NormalRandom.Next(min, max);
|
|
}
|
|
|
|
public static void NextBytes(byte[] buffer) {
|
|
SecureRandom.GetBytes(buffer);
|
|
}
|
|
}
|
|
}
|