added GetHash helper
All checks were successful
Publish NuGet Packages / build-and-publish (push) Successful in 25s
All checks were successful
Publish NuGet Packages / build-and-publish (push) Successful in 25s
This commit is contained in:
parent
c6e6b29905
commit
b498ec8616
@ -1,3 +1,5 @@
|
|||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
using Svrnty.GeoManagement.Abstractions.Abstractions;
|
using Svrnty.GeoManagement.Abstractions.Abstractions;
|
||||||
using Svrnty.GeoManagement.Abstractions.Models;
|
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}";
|
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