[backend/helpers] Fix random string lengths, make sure random strings don't contain the = character
This commit is contained in:
parent
a8c78aed36
commit
f83273c150
1 changed files with 3 additions and 5 deletions
|
@ -4,9 +4,7 @@ namespace Iceshrimp.Backend.Core.Helpers;
|
||||||
|
|
||||||
public static class CryptographyHelpers
|
public static class CryptographyHelpers
|
||||||
{
|
{
|
||||||
public static string GenerateRandomString(int length) =>
|
private const string AlphaNumCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
Convert.ToBase64String(RandomNumberGenerator.GetBytes(length));
|
public static string GenerateRandomString(int length) => RandomNumberGenerator.GetString(AlphaNumCharset, length);
|
||||||
|
public static string GenerateRandomHexString(int length) => RandomNumberGenerator.GetHexString(length, true);
|
||||||
public static string GenerateRandomHexString(int length) =>
|
|
||||||
Convert.ToHexString(RandomNumberGenerator.GetBytes(length)).ToLowerInvariant();
|
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue