ab56a9bcf7
SVN-Revision: r240
75 lines
2.1 KiB
C#
75 lines
2.1 KiB
C#
/******************************
|
|
* 说明:密码加密类
|
|
* 创建人:龚宇超
|
|
* 创建日期:2017-08-12
|
|
* 修改人:
|
|
* 修改日期:
|
|
* 修改备注:
|
|
* 版本:1.0.0.0
|
|
******************************/
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Security.Cryptography;
|
|
|
|
namespace Lskj.Util
|
|
{
|
|
/// <summary>
|
|
/// 密码加密类
|
|
/// </summary>
|
|
public sealed class SHAHelper
|
|
{
|
|
/// <summary>
|
|
/// <para>说明:加密密码</para>
|
|
/// <para>创建人:龚宇超</para>
|
|
/// <para>创建日期:2017-08-12 </para>
|
|
/// <para>修改人:</para>
|
|
/// <para>修改日期:</para>
|
|
/// <para>修改备注:</para>
|
|
/// <para>版本:1.0</para>
|
|
/// </summary>
|
|
/// <param name="password">The password.</param>
|
|
/// <returns>System.String.</returns>
|
|
public static string EncryptPassword(string password)
|
|
{
|
|
password = "2006" + password + "New System";
|
|
byte[] bytePassword = System.Text.Encoding.ASCII.GetBytes(password);
|
|
SHA1 sha = new SHA1CryptoServiceProvider();
|
|
byte[] dataHashed = sha.ComputeHash(bytePassword);
|
|
return BitConverter.ToString(dataHashed).Replace("-", "");
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// md5加密
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public static string GetMd5Hash(string input)
|
|
{
|
|
using (MD5 md5 = MD5.Create())
|
|
{
|
|
// 将字符串转换为字节数组并计算其哈希数据
|
|
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
|
|
byte[] hashBytes = md5.ComputeHash(inputBytes);
|
|
|
|
// 将得到的哈希值转换为16进制字符串
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < hashBytes.Length; i++)
|
|
{
|
|
sb.Append(hashBytes[i].ToString("X2"));
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
} |