22 lines
530 B
C#
22 lines
530 B
C#
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace SpaceGame.Api.Auth.Simulation;
|
|
|
|
public sealed class RefreshTokenFactory
|
|
{
|
|
public string CreateToken()
|
|
{
|
|
Span<byte> bytes = stackalloc byte[32];
|
|
RandomNumberGenerator.Fill(bytes);
|
|
return Convert.ToBase64String(bytes);
|
|
}
|
|
|
|
public string HashToken(string token)
|
|
{
|
|
using var sha = SHA256.Create();
|
|
var bytes = sha.ComputeHash(Encoding.UTF8.GetBytes(token));
|
|
return Convert.ToHexString(bytes);
|
|
}
|
|
}
|