山东雷驰
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.
 
 
 
 

24 lines
650 B

using System;
using System.Security.Cryptography;
using System.Text;
namespace Kean.Infrastructure.Utilities
{
/// <summary>
/// Sha256加密
/// </summary>
public sealed class Sha256Encoding
{
/// <summary>
/// 256位散列加密
/// </summary>
/// <param name="text">明文</param>
/// <returns>密文</returns>
public static string Encode(string text)
{
var sha256 = SHA256.Create();
var bytes = sha256.ComputeHash(Encoding.Default.GetBytes(text));
return BitConverter.ToString(bytes).Replace("-", string.Empty);
}
}
}