This commit is contained in:
2026-06-10 13:06:55 -07:00
parent d1a41d84d7
commit b871e0da32
987 changed files with 22413 additions and 21031 deletions

View File

@@ -0,0 +1,22 @@
using System.Security.Cryptography;
using System.Text;
namespace MicCheck.Api.ApiKeys;
public static class ApiKeyHasher
{
public static string Hash(string key)
{
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(key));
return Convert.ToHexString(bytes).ToLowerInvariant();
}
public static string GenerateKey()
{
var bytes = RandomNumberGenerator.GetBytes(32);
return Convert.ToBase64String(bytes)
.TrimEnd('=')
.Replace('+', '-')
.Replace('/', '_');
}
}