From 5eaf3547dcf56630d5a4088a4c2f42971cbbee41 Mon Sep 17 00:00:00 2001 From: max Date: Sat, 16 Nov 2024 14:54:34 +0100 Subject: [PATCH] Random uint util --- Nerfed.Runtime/Util/RandomId.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Nerfed.Runtime/Util/RandomId.cs diff --git a/Nerfed.Runtime/Util/RandomId.cs b/Nerfed.Runtime/Util/RandomId.cs new file mode 100644 index 0000000..7ef0a2b --- /dev/null +++ b/Nerfed.Runtime/Util/RandomId.cs @@ -0,0 +1,13 @@ +using System.Security.Cryptography; + +namespace Nerfed.Runtime.Util; + +public static class RandomId +{ + public static uint GenerateSecureRandomUInt() + { + byte[] buffer = new byte[4]; + RandomNumberGenerator.Fill(buffer); + return BitConverter.ToUInt32(buffer, 0); + } +} \ No newline at end of file