java ºÍ.netµÄMD5¼ÓÃܲ»Ò»Ñù£¿£¡
ÓÉÓÚ¹¤×÷ÐèÒª£¬ÒªÓÃ.netµÄ³ÌÐòµ÷ÓÃÒ»¸öjava±àдµÄweb service½Ó¿Ú£¬½Ó¿ÚµÄÒ»¸ö²ÎÊýÒªÇómd5·½Ê½¼ÓÃÜ¡£
.netÖеÄmd5¼ÓÃÜÊǺÜÈÝÒ׵쬲ÉÓÃmsdnÖиø³öµÄ·½·¨:
// Hash an input string and return the hash as
// a 32 character hexadecimal string.
static string getMd5Hash(string input)
{
// Create a new instance of the MD5CryptoServiceProvider object.
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
// 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();
}
¿ÉÊÇ£¬µ±ÊäÈëµÄ×Ö·û´®ÊÇÖÐÎĵÄʱºò£¬ÎÊÌâ³öÏÖÁË£¬¼ÓÃܳöÀ´µÄ×Ö·û´®²»Ò»Ñù£º
ÊäÈë ¹¤×÷
java 8c87df93416ebdf251bcb6b328ec3c3b
.net 12e709e3a9a82b441b739a5c8ba035de
Ê×ÏÈÏëµ½µÄÊǶÔÖÐÎĵıàÂ뷽ʽ²»Ò»Ñù£¬¿ÉÊÇÎÞÂÛÓÃutf8»¹ÊÇunicode½á¹û¶¼²»Í¬¡£
ÓÃgoogleËÑË÷ “java MD5 Ëã·¨”ÕÒµ½µÄһƪÎÄÕ½âÊÍÁËÎÒµÄÒÉ»ó
http://blog.csdn.net/Peter_K/archive/2007/03/13/1527629.aspx
char[] charArray = inStr.toCharArray();
byte[] byteArray = new byte[charArray.length];
for (int i = 0; i < charArray.length; i++)
byteArray[i] = (byte) charArray[i];
byte[] md5Bytes = md5.digest(byteArray);
ÔÚ.netÖÐÓÃͬÑùµÄ·½Ê½
private string getMd5Hash(string input)
{
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
// Convert the input string to a byte array and compute the hash.
char[] temp = input.ToCharArray();
Ïà¹ØÎĵµ£º
±¾ÈË֮ǰ×öµÄÏîÄ¿ÖлýÀÛ³£ÓõÄʱ¼ä·½·¨£¬Ìù³öÀ´Óë´ó¼Ò¹²Ïí£¬Èç¹ûÄÄÀïÓдíÎó»ò¸üÓÐЧµÄ·½·¨Ç뾡¹ÜÅÄש£¡¹þ¹þ
Java´úÂë
package com.hefeng.test;
import java.text.DateFormat;
import java.text.ParsePosition;
import&n ......
ÔÎĵØÖ·£ºhttp://hi.baidu.com/lin_zy/blog/item/bf14d21f6bb12ff6e1fe0bf1.html
¸ÅÄî
ʲôÊÇÒì³££¿
Òì³££¨exception£©Ó¦¸ÃÊÇÒ쳣ʼþ£¨exceptional event£©µÄËõд¡£
Òì³£¶¨Ò壺Òì³£ÊÇÒ»¸öÔÚ³ÌÐòÖ´ÐÐÆÚ¼ä·¢ÉúµÄʼþ£¬ËüÖжÏÕýÔÚÖ´ÐеijÌÐòµÄÕý³£µÄÖ¸ÁîÁ÷¡£
µ±ÔÚÒ»¸ö·½·¨Öз¢Éú´íÎóµÄʱºò£¬Õâ¸ö·½·¨´´½¨Ò»¸ö¶ÔÏ󣬲¢ÇÒ ......
ºÜ¶àÈËÔÚ³õѧJavaµÄʱºò¾³£»á±»ÊéÖнéÉܵÄÒ»¶Ñ»·¾³±äÁ¿µÄÉèÖøãµÃÍ·»èÄÔÕÍ£¬ºÜ¶àÊéÖж¼»áÔÚ³õ×°JDKµÄʱºòÈÃËû´ó¼ÒÉèÖÃJAVA_HOME»·¾³±ä
Á¿£¬ÔÚ¿ª·¢³ÌÐòµÄʱºòÉèÖÃCLASSPATH»·¾³±äÁ¿£¬¶øºÜ¶àÈ˲¢²»Àí½âÕâÁ½¸ö»·¾³±äÁ¿µÄ×÷Óã¬ÎÒÃÇÀ´·Ö±ð½øÐÐÏêϸµÄ²ûÊö¡£
Ê×ÏÈÊÇJAVA_HOME»·¾³±äÁ¿£¬ÎÒÃÇÏÈÀ´ ......
Ò»¡¢static
ÇëÏÈ¿´ÏÂÃæÕâ¶Î³ÌÐò£º
public class Hello{
public static void main(String[] args){//(1)
System.out.println("Hello,world!");//(2)
}
}
¿´¹ýÕâ¶Î³ÌÐò£¬¶ÔÓÚ´ó¶àÊýѧ¹ýJava µÄ´ÓÀ´Ëµ£¬¶¼²»Ä°Éú¡£¼´Ê¹Ã»ÓÐѧ¹ýJava£¬¶øÑ§¹ýÆäËüµÄ¸ß¼¶ÓïÑÔ£¬ÀýÈçC£¬ÄÇÄúÒ²Ó¦¸ÃÄÜ¿´¶®Õâ¶Î´úÂëµÄÒâ˼¡£ËüÖ»ÊǼòµ ......
21 Àà = Óò + ·½·¨
Óò = Êý¾Ý
·½·¨ = ¹¦ÄÜ
22 ÒýÓÃÊý¾ÝÀàÐͱäÁ¿µÄËĸöÊôÐÔ£º¢Ù±äÁ¿Ãû ¢ÚÊý¾ÝÀàÐÍ ¢Û´æ´¢µ¥Ôª ¢Ü±äÁ¿Öµ
23 ÔÚÒýÓÃÊý¾ÝÀàÐͱäÁ¿´æ´¢µ¥ÔªÄÚ´æ·ÅµÄ±äÁ¿ÖµÊÇÒýÓ㬼´Ö¸ÏòÊ ......