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