26 lines
658 B
C#
26 lines
658 B
C#
using System.Security.Cryptography;
|
|
|
|
namespace Application.Helpers;
|
|
|
|
public static class KeyGenerator
|
|
{
|
|
public static string GenerateApiKey()
|
|
{
|
|
using (var rng = RandomNumberGenerator.Create())
|
|
{
|
|
var apiKeyBytes = new byte[32];
|
|
rng.GetBytes(apiKeyBytes);
|
|
return Convert.ToBase64String(apiKeyBytes);
|
|
}
|
|
}
|
|
|
|
public static string GenerateJwtSecretKey()
|
|
{
|
|
using (var rng = RandomNumberGenerator.Create())
|
|
{
|
|
var keyBytes = new byte[32]; // 256 bits
|
|
rng.GetBytes(keyBytes);
|
|
return Convert.ToBase64String(keyBytes);
|
|
}
|
|
}
|
|
} |