Add Meta authentication secret and SHA256 hashing
This commit is contained in:
19
src/RecNet.Application/Common/Security/Hashing.cs
Normal file
19
src/RecNet.Application/Common/Security/Hashing.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace RecNet.Application.Common.Security;
|
||||
|
||||
public static class Hashing
|
||||
{
|
||||
public static byte[] ComputeSha256(string input)
|
||||
=> SHA256.HashData(Encoding.UTF8.GetBytes(input));
|
||||
|
||||
public static bool VerifySha256(string input, byte[] expectedHash)
|
||||
{
|
||||
var computedHash = ComputeSha256(input);
|
||||
|
||||
return CryptographicOperations.FixedTimeEquals(
|
||||
computedHash,
|
||||
expectedHash);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user