javaÖÐ×Ö·û´® MD5ÃÜÂëµÄ¼ÓÃÜÓëÑéÖ¤
Õª×Ô£ºjava JDK ʵÀý±¦µä
MD5¼´Message-Digest Algorithm 5£¨ÐÅÏ¢-ÕªÒªËã·¨ 5£©£¬ÓÃÓÚÈ·±£ÐÅÏ¢´«ÊäÍêÕûÒ»Ö¡£ÊǼÆËã»ú¹ã·ºÊ¹ÓõÄÔÓ´ÕËã·¨Ö®Ò»£¨ÓÖÒëÕªÒªËã·¨¡¢¹þÏ£Ëã·¨£©£¬Ö÷Á÷±à³ÌÓïÑÔÆÕ±éÒÑÓÐMD5ʵÏÖ¡£
¡¡¡¡ ½«Êý¾Ý£¨È纺×Ö£©ÔËËãΪÁíÒ»¹Ì¶¨³¤¶ÈÖµÊÇÔÓ´ÕËã·¨µÄ»ù´¡ÔÀí£¬MD5µÄÇ°ÉíÓÐMD2¡¢MD3ºÍMD4¡£
±¾ÊµÀý½éÉÜÓÃMD5½øÐмÓÃܺÍÑéÖ¤£¬½«ÊäÈë×Ö·û´®Í¨¹ýMD5¼ÓÃܳÉÁíÒ»¸ö×Ö·û´®£¬¶øÇÒ¸ù¾ÝеÄ×Ö·û´®ÎÞ·¨»ñµÃÔ×Ö·û´®£¬µ«¿ÉÒÔÔÚ²»ÖªµÀÔʼÃÜÂëµÄÇé¿öϽøÐÐÃÜÂëÑéÖ¤¡£
¹Ø¼ü¼¼Êõ£º
*ͨ¹ýjava.security.MessageDigestµÄ¾²Ì¬·½·¨getInstance´´½¨¾ßÓÐÖ¸¶¨Ëã·¨Ãû³ÆµÄÐÅÏ¢ÕªÒª£¬²ÎÊýΪËã·¨Ãû£¬´«Èë“MD5”Ôò±íʾ½«Ê¹ÓÃMD5Ëã·¨¡£
*MessageDigestµÄdigestʵÀý·½·¨Ê¹ÓÃÖ¸¶¨µÄ×Ö½ÚÊý×é¶ÔÕªÒª½øÐÐ×îºó¸üУ¬È»ºóÍê³ÉÕªÒª¼ÆË㣬·µ»Ø´æ·Å¹þÏ£Öµ½á¹ûµÄ¼¾½ÚÊý×飬Õâ¸öÊý×é¾ÍÊÇMD5¼ÓÃܲúÆ·¡£
*½«¼ÓÃܺóµÄ×Ö½ÚÊý×éת»»³ÉÊ®Áù½øÖƵÄ×Ö·û´Ü£¬ÐγÉ×îÖÕµÄÃÜÂë¡£
*µ±ÊäÈë×Ö·û´®¾¹ýMD5¼ÓÃܺ󣬵õ½µÄ×Ö·û´®ÓëÃÜÂëÒ»Ñù£¬ÔòÈÏΪÃÜÂëÑé֤ͨ¹ý¡£
ʵÀýÑÝʾ£º
import java.security.MessageDigest;
/**
*
* @author Ñã¹ýÁôÉù
*/
public class Password {
//16½øÖÆÏÂÊý×Öµ½×Ö·ûµÄÓ³ÉäÊý×é
private static String[] hexDigits = new String[]{"0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"};
//½«inputstr¼ÓÃÜ
public static String createPassword(String inputstr)
{
return encodeByMD5(inputstr);
}
//ÑéÖ¤ÃÜÂëÊÇ·ñÕýÈ·
public static boolean authenticatePassword(String pass , String inputstr)
{
if(pass.equals((encodeByMD5(inputstr))))
{
return true;
}
else
{
return false;
}
}
//¶Ô×Ö·û´®½øÐÐMD5±àÂë
private static String encodeByMD5(String originstr)
{
if(originstr !=null)
{
try{
//´´½¨¾ßÓÐÖ¸¶¨Ëã·¨Ãû³ÆµÄÐÅÏ¢ÕªÒª
MessageDigest md = MessageDigest.getInstance("MD5");
//ʹÓÃÖ¸¶¨µÄ×Ö½ÚÊý×é¶ÔÕªÒª½øÐÐ×îºóµÄ¸üУ¬È»ºóÍê³ÉÕªÒª¼ÆËã
byt
Ïà¹ØÎĵµ£º
import java.net.*;
import java.io.*;
public class ReadDemo
{
public static void main(String argv[])
{
try
{
URL url = new URL("http://blog.chinaunix.net/u/15586/showart_1863289.html");
BufferedRe ......
java »ù±¾Êý¾ÝÀàÐÍÖ®¼äµÄת»»
ʵ¼ýÍ·±íʾÎÞÊý¾Ý¶ªÊ§µÄת»»
Ðé¼ýÍ·±íʾÓÐÊý¾Ý¶ªÊ§µÄת»»
ÔÚ½øÐжþÔª¼ÆËãµÄʱºò£¬ÏȽ«Á½¸ö²Ù×÷Êýת»»ÎªÍ¬Ò»ÖÖÀàÐÍ£¬ÔÙ¼ÆËã
¢ÙÈç¹ûÁ½¸öÊýÖÐÓÐÒ»¸öÊÇdoubleÀàÐ͵ģ¬ÄÇôÁíÒ»¸öÒ²½«×ª»»ÎªdoubleÀàÐÍ;
&n ......
Person p=new Person();
ÕâÊÇʲô?µ±È»ÊÇʵÀý»¯Ò»¸ö¶ÔÏóÁË.¿ÉÊÇÕâÖÖʵÀý»¯¶ÔÏóµÄ·½·¨´æÔÚÒ»¸öÎÊÌâ,ÄǾÍÊDZØÐëÒªÖªµÀÀàÃû²Å¿ÉÒÔʵÀý»¯ËüµÄ¶ÔÏó,ÕâÑùÎÒÃÇÔÚÓ¦Ó÷½Ãæ¾Í»áÊܵ½ÏÞÖÆ.ÄÇôÓÐûÓÐÕâÑùÒ»ÖÖ·½Ê½,ÈÃÎÒÃDz»ÖªµÀÕâ¸öÀàµÄÀàÃû¾Í¿ÉÒÔʵÀý»¯ËüµÄ¶ÔÏóÄØ?Thank Goodness!ÐÒ¿÷ÎÒÃÇÓõÄÊÇjava, java¾ÍÌṩÁËÕâÑùµÄ»úÖÆ.
1).ja ......
(1) transient:
Èç¹ûÓÃtransientÉùÃ÷Ò»¸öʵÀý±äÁ¿£¬µ±¶ÔÏó´æ´¢Ê±£¬ËüµÄÖµ²»ÐèҪά³Ö¡£ÀýÈ磺
class T
{
transient int a; //²»ÐèҪά³Ö
int b; //ÐèҪά³Ö
} //ÕâÀÈç¹ûTÀàµÄÒ»¸ö¶ÔÏóдÈëÒ»¸ö³Ö¾ÃµÄ´æ´¢ÇøÓò£¬aµ ......
±êÌâ ÔÚJavaÖÐʵÏÖ¸¡µãÊýµÄ¾«È·¼ÆËã AYellow£¨Ô×÷£© ÐÞ¸Ä
¹Ø¼ü×Ö Java ¸¡µãÊý ¾«È·¼ÆËã
ÎÊÌâµÄÌá³ö£º
Èç¹ûÎÒÃDZàÒëÔËÐÐÏÂÃæÕâ¸ö³ÌÐò»á¿´µ½Ê²Ã´£¿
public class Test{
public static void mai ......