feat(infra): implement RefreshTokenGenerator with cryptographic random bytes
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using SIGCM2.Application.Abstractions.Security;
|
||||||
|
|
||||||
|
namespace SIGCM2.Infrastructure.Security;
|
||||||
|
|
||||||
|
public sealed class RefreshTokenGenerator : IRefreshTokenGenerator
|
||||||
|
{
|
||||||
|
public string Generate()
|
||||||
|
{
|
||||||
|
Span<byte> bytes = stackalloc byte[32];
|
||||||
|
RandomNumberGenerator.Fill(bytes);
|
||||||
|
return Convert.ToBase64String(bytes)
|
||||||
|
.TrimEnd('=')
|
||||||
|
.Replace('+', '-')
|
||||||
|
.Replace('/', '_');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user