/******************************
* 说明:密码加密类
* 创建人:龚宇超
* 创建日期: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
{
///
/// 密码加密类
///
public sealed class SHAHelper
{
///
/// 说明:加密密码
/// 创建人:龚宇超
/// 创建日期:2017-08-12
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// The password.
/// System.String.
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("-", "");
}
///
/// md5加密
///
///
///
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();
}
}
}
}