You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
564 B
20 lines
564 B
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace System;
|
|
|
|
internal static class AbpStringCryptographyExtensions
|
|
{
|
|
public static string Sha256(this string planText, byte[] salt)
|
|
{
|
|
var data = planText.GetBytes();
|
|
using var hmacsha256 = new HMACSHA256(salt);
|
|
var retVal = hmacsha256.ComputeHash(data);
|
|
var sb = new StringBuilder();
|
|
for (var i = 0; i < retVal.Length; i++)
|
|
{
|
|
sb.Append(retVal[i].ToString("x2"));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
|