18 lines
410 B
C#
18 lines
410 B
C#
using System.Security.Cryptography;
|
|
|
|
namespace MxGateway.Server.Security.Authentication;
|
|
|
|
public static class ApiKeySecretGenerator
|
|
{
|
|
public static string Generate()
|
|
{
|
|
Span<byte> bytes = stackalloc byte[32];
|
|
RandomNumberGenerator.Fill(bytes);
|
|
|
|
return Convert.ToBase64String(bytes)
|
|
.TrimEnd('=')
|
|
.Replace('+', '-')
|
|
.Replace('/', '_');
|
|
}
|
|
}
|