bookmark-manager-r4/Classes/Crypto.cs

22 lines
572 B
C#
Raw Normal View History

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;
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();
}
}
}
}