feat: add local authentication
This commit is contained in:
20
Tiku.Infrastructure/Auth/SmsCodeHashing.cs
Normal file
20
Tiku.Infrastructure/Auth/SmsCodeHashing.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Tiku.Domain.Tenancy;
|
||||
|
||||
namespace Tiku.Infrastructure.Auth;
|
||||
|
||||
public static class SmsCodeHashing
|
||||
{
|
||||
public static string Hash(Guid tenantId, string phone, SmsPurpose purpose, string code)
|
||||
{
|
||||
var normalized = $"{tenantId:N}:{NormalizePhone(phone)}:{purpose}:{code.Trim()}";
|
||||
var hash = SHA256.HashData(Encoding.UTF8.GetBytes(normalized));
|
||||
return Convert.ToHexString(hash).ToLowerInvariant();
|
||||
}
|
||||
|
||||
public static string NormalizePhone(string phone)
|
||||
{
|
||||
return phone.Trim();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user