sharp-chat/SharpChat/RNG.cs

26 lines
676 B
C#
Raw Normal View History

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() {
return NormalRandom.Next();
2022-08-30 15:00:58 +00:00
}
public static int Next(int max) {
return NormalRandom.Next(max);
2022-08-30 15:00:58 +00:00
}
public static int Next(int min, int max) {
return NormalRandom.Next(min, max);
2022-08-30 15:00:58 +00:00
}
public static void NextBytes(byte[] buffer) {
SecureRandom.GetBytes(buffer);
2022-08-30 15:00:58 +00:00
}
}
}