22 lines
552 B
C#
22 lines
552 B
C#
|
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 = new SHA256Managed())
|
|||
|
{
|
|||
|
byte[] hash = sha.ComputeHash(Encoding.UTF8.GetBytes(text));
|
|||
|
|
|||
|
return BitConverter.ToString(hash).Replace("-", string.Empty) + "+" + text.Length.ToString();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|