Skip to content

Commit 2cafd97

Browse files
authored
Merge pull request #25 from Neo-vortex/GenerateToken-optimzation
Generate token optimzation
2 parents 7f87b21 + 451bfd4 commit 2cafd97

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/KSFramework/Utilities/SecurityHelper.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public static string GetSha256Hash(string input)
1515

1616
public static string GenerateToken(int byteLength = 32)
1717
{
18-
var randomNumber = new byte[byteLength];
19-
using var rng = RandomNumberGenerator.Create();
20-
rng.GetBytes(randomNumber);
18+
Span<byte> randomNumber = stackalloc byte[byteLength];
19+
RandomNumberGenerator.Fill(randomNumber);
2120
return Convert.ToBase64String(randomNumber);
2221
}
2322
}

0 commit comments

Comments
 (0)