这是我的问题
我有这样的代码,它接受带有密码的干净文本并返回Base64MD5散列。
private static string GetMd5Base64Pass(string userpwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
return Convert.ToBase64String(md5.ComputeHash(Encoding.ASCII.GetBytes(userpwd)));
}
我需要重用它来接受MD5字符串散列并在Base64MD5中返回。
我试过这样做:
private static string GetMd5Base64PassMD5(string userpwd)
{
MD5 md5 = new MD5CryptoServiceProvider();
return Convert.ToBase64String(Encoding.ASCII.GetBytes(userpwd));
}
但回报是完全不同的。
已经尝试将字符串转换为字节数组,但没有工作。
我需要插入一个带有32位MD5的字符串,并在Base64String中返回它。
特克斯
示例:
密码是123123:
MD5为:4297f44b13955555245b2497399d7a93
Base64String of MD5是: Qpf0SxOVUjUkWySXOZ16kw==
我要去找
这个: Qpf0SxOVUjUkWySXOZ16kw==
从…
此散列字符串4297f44b13955235245b2497399d7a93
发布于 2013-12-04 16:30:00
public static string ConvertHexStringToBase64(string hexString)
{
byte[] buffer = new byte[hexString.Length / 2];
for (int i = 0; i < hexString.Length; i++)
{
buffer[i / 2] = Convert.ToByte(Convert.ToInt32(hexString.Substring(i, 2), 16));
i += 1;
}
string res = Convert.ToBase64String(buffer);
return res;
}
它接收md5字符串散列并将其转换为Base64十六进制。
https://stackoverflow.com/questions/20374524
复制相似问题