[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 string GenerateRandomString(int length) =>
|
||||
Convert.ToBase64String(RandomNumberGenerator.GetBytes(length));
|
||||
|
||||
public static string GenerateRandomHexString(int length) =>
|
||||
Convert.ToHexString(RandomNumberGenerator.GetBytes(length)).ToLowerInvariant();
|
||||
private const string AlphaNumCharset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||
public static string GenerateRandomString(int length) => RandomNumberGenerator.GetString(AlphaNumCharset, length);
|
||||
public static string GenerateRandomHexString(int length) => RandomNumberGenerator.GetHexString(length, true);
|
||||
}
|
Loading…
Add table
Reference in a new issue