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