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.
25 lines
650 B
25 lines
650 B
3 months ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
}
|