Skip to content

建议原函数名MD5Encrypt64改为MD5EncryptBase64 #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions SwiftCode.BBS.Common/Helper/MD5Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,19 @@ public static string MD5Encrypt32(string password = "")
}

/// <summary>
/// 64位MD5加密
/// MD5加密,base64编码
/// </summary>
/// <param name="password"></param>
/// <returns></returns>
public static string MD5Encrypt64(string password)
//public static string MD5Encrypt64(string password)
public static string MD5Encrypt64Base64(string password)
{
// 实例化一个md5对像
// 加密后是一个字节类型的数组,这里要注意编码UTF8/Unicode等的选择 
MD5 md5 = MD5.Create();
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password));
return Convert.ToBase64String(s);
byte[] s = md5.ComputeHash(Encoding.UTF8.GetBytes(password)); //16字节数组
return Convert.ToBase64String(s); //生成的base64字符串长度是24
//所以建议将函数名改为MD5EncryptBase64
}

}
Expand Down