This commit is contained in:
2021-10-21 19:04:14 +00:00
parent e130c290f5
commit 0a7a00639a
2 changed files with 3 additions and 5 deletions

View File

@@ -52,16 +52,14 @@ namespace AyaNova.Util
{
if (length < 0)
throw new ArgumentException("length must not be negative", "length");
if (length > int.MaxValue / 8) // 250 million chars ought to be enough for anybody
if (length > int.MaxValue / 8)
throw new ArgumentException("length is too big", "length");
if (characterSet == null)
throw new ArgumentNullException("characterSet");
var characterArray = characterSet.Distinct().ToArray();
if (characterArray.Length == 0)
throw new ArgumentException("characterSet must not be empty", "characterSet");
var bytes = new byte[length * 8];
//new RNGCryptoServiceProvider().GetBytes(bytes);
RandomNumberGenerator.Create().GetBytes(bytes);
var result = new char[length];
for (int i = 0; i < length; i++)