From ff07ff631aa8414dd1efcb1211f4d9ec838cb21b Mon Sep 17 00:00:00 2001 From: Matthew Carney Date: Tue, 27 Jun 2023 22:52:03 +0100 Subject: [PATCH] Replaced RNGCryptoServiceProvider --- src/Utils/Helper.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Utils/Helper.cs b/src/Utils/Helper.cs index 922a733..a528029 100644 --- a/src/Utils/Helper.cs +++ b/src/Utils/Helper.cs @@ -90,15 +90,9 @@ public static bool IsBetween(long value, long left, long right) /// public static String RandomString(int len = 11) { - string result; - - using (RandomNumberGenerator rng = new RNGCryptoServiceProvider()) - { - byte[] rngToken = new byte[len + 1]; - rng.GetBytes(rngToken); - - result = Convert.ToBase64String(rngToken); - } + RandomNumberGenerator.Create(); + byte[] randomBytes = RandomNumberGenerator.GetBytes(len); + string result = Convert.ToBase64String(randomBytes); // Remove '=' from end of string return result.Remove(result.Length - 1);