Text asp.net中的文本到md5转换脚本
我有一个asp.net 2.0中的网站,因为我需要使用CCNOW付款集成进行付款,但为此,我必须以MD5格式向CCNOW发送请求,但我无法将我的值生成为CCNOW MD5格式。所以,你能不能请任何人有一个脚本/函数,可以将给定的字符串转换成MD5?不是一种格式,而是一种哈希算法。使用假设您使用的是C,它看起来像:Text asp.net中的文本到md5转换脚本,text,md5,Text,Md5,我有一个asp.net 2.0中的网站,因为我需要使用CCNOW付款集成进行付款,但为此,我必须以MD5格式向CCNOW发送请求,但我无法将我的值生成为CCNOW MD5格式。所以,你能不能请任何人有一个脚本/函数,可以将给定的字符串转换成MD5?不是一种格式,而是一种哈希算法。使用假设您使用的是C,它看起来像: static string getMd5Hash(string input) { // Create a new instance of the MD5CryptoServic
static string getMd5Hash(string input)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5 md5Hasher = MD5.Create();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
// Create a new Stringbuilder to collect the bytes
// and create a string.
StringBuilder sBuilder = new StringBuilder();
// Loop through each byte of the hashed data
// and format each one as a hexadecimal string.
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
// Return the hexadecimal string.
return sBuilder.ToString();
}
public static string GetMD5(string value) {
MD5 md5 = MD5.Create();
byte[] md5Bytes = System.Text.Encoding.Default.GetBytes(value);
byte[] cryString = md5.ComputeHash(md5Bytes);
string md5Str = string.Empty;
for (int i = 0; i < cryString.Length; i++) {
md5Str += cryString[i].ToString("X");
}
return md5Str;
}
GetMD5(stringToConvert);