2021-09-21 12:28:52 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace BookmarkManager
|
|
|
|
|
{
|
|
|
|
|
public class Crypto
|
|
|
|
|
{
|
|
|
|
|
public static string GetSHA256Hash(string text)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(text)) return string.Empty;
|
2022-12-23 22:20:26 +00:00
|
|
|
|
|
|
|
|
|
using (var sha = SHA256.Create())
|
2021-09-21 12:28:52 +00:00
|
|
|
|
{
|
|
|
|
|
byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes(text));
|
|
|
|
|
|
|
|
|
|
return BitConverter.ToString(hash).Replace("-", string.Empty) + "+" + text.Length.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|