日期:2014-05-20 浏览次数:21211 次
MessageDigest mdInst = MessageDigest.getInstance("MD5");
byte[] md = mdInst.digest(value.getBytes());//value为认证的原文
String md5 = "";
for(int i=0;i<md.length;i++)
{
md5+=("" + "0123456789ABCDEF".charAt(0xf & md[i] >> 4 + "0123456789ABCDEF".charAt(md[i] & 0xf));
}
byte[] Buffer = Encoding.Default.GetBytes(value);
MD5 md5 = MD5.Create();
byte[] tempMD5Value = md5.ComputeHash(Buffer);
string strMD5Value = string.Empty;
for (int i = 0; i < tempMD5Value.Length; i++)
{
strMD5Value += ("" + md5Str.Substring(0xf & tempMD5Value[i] >> 4, 1) + md5Str.Substring(tempMD5Value[i] & 0xf, 1));
}
string value = "1234567";
string md5Str = "0123456789ABCDEF";
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] buffer = md5.ComputeHash(Encoding.Default.GetBytes(value));
string strMD5Value = string.Empty;
for (int i = 0; i < buffer.Length; i++)
{
int a = 0xf & buffer[i] >> 4;
int b = buffer[i] & 0xf;
strMD5Value += md5Str.Substring(0xf & buffer[i] >> 4, 1) + md5Str[buffer[i] & 0xf];
}
MessageBox.Show(strMD5Value);//FCEA920F7412B5DA7BE0CF42B8C93759
try {
MessageDigest mdInst = MessageDigest.getInstance("md5");
String value = "1234567";
byte[] md = mdInst.digest(value.getBytes());// value为认证的原文
String md5 = "";
for (int i = 0; i < md.length; i++) {
int a = 0xf & md[i] >> 4;
int b = md[i] & 0xf;
md5+=("" + "0123456789ABCDEF".charAt(0xf & md[i] >> 4) + "0123456789ABCDEF".charAt(md[i] & 0xf));
}
System.out.println(md5);//FCEA920F7412B5DA7BE0CF42B8C93759
} catch (Exception e) {
}