Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
b498ec8616 |
@ -1,3 +1,5 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Svrnty.GeoManagement.Abstractions.Abstractions;
|
||||
using Svrnty.GeoManagement.Abstractions.Models;
|
||||
|
||||
@ -65,4 +67,16 @@ public static class ServiceCollectionExtensions
|
||||
|
||||
return $"{address.Line2}, {address.Line1}\n{address.City}, {address.Subdivision} {address.PostalCode}\n{address.CountryCode}";
|
||||
}
|
||||
|
||||
public static string GetHash(this IAddress address)
|
||||
=> ComputeSha256Hex(address.GetFormattedAddress());
|
||||
|
||||
private static string ComputeSha256Hex(string input)
|
||||
{
|
||||
using SHA256 sha256 = SHA256.Create();
|
||||
byte[] bytes = Encoding.UTF8.GetBytes(input);
|
||||
byte[] hash = sha256.ComputeHash(bytes);
|
||||
|
||||
return Convert.ToHexString(hash).ToLower();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user