±¨Îļø±ðÔÚÉí·ÝÈÏÖ¤ÖÐÕ¼ÖØҪλÖã¬ÊÇÈÏ֤ϵͳµÄÒ»¸öÖØÒª»·½Ú£¬ÔÚ½ðÈÚºÍÉÌҵϵͳÖй㷺ӦÓá£
±¨Îļø±ð³£Óñ¨Îļø±ðÂ루Message Authentication Code,¼´MAC£©×÷Ϊ¼ø±ðµÄ»ù´¡£¬
Æä»ù±¾ÔÀíÊÇ£ºÓÃÒ»¸öÃÜÔ¿£¨£¨private Key£©£©Éú³ÉÒ»¸öСÊý¾Ý¿é¸½¼ÓÔÚÒª´«ÊäµÄ±¨ÎĺóÃæ¡£ÕâÖÖ¼¼ÊõÊǼٶ¨Í¨Ñ¶Ë«·½¹²ÏíÒ»¸öÃÜÔ¿K£¬µ±Í¨Ñ¶µÄÒ»·½Òª¸øÁíÒ»·½´«ÊäÊý¾ÝMʱ£¬Í¨¹ýÌض¨µÄËã·¨¼ÆËã³ö¸Ã±¨ÎÄMµÄMAC£½F£¨K£¬M£©£¬ÕâÀïµÄF¾ÍÊÇÖ¸¼ø±ðÔËË㺯Êý£¬È»ºó±¨ÎÄÊý¾ÝMºÍMACÒ»Æð´«Ë͸øÁíÒ»·½¡£µ±ÁíÒ»·½ÊÕµ½Êý¾Ýʱ£¬ÏÈÓÃͬÑùµÄËã·¨F¼ÆËãMAC£¬ºÍ´«Êä¹ýÀ´µÄMAC½øÐбȽϣ¬Èç¹ûÏàͬ£¬ÔòÈÏΪÊý¾ÝÊÇÕýÈ·µÄ¡£ ¼ø±ðº¯Êý³£±»ÈÏΪÊǼÓÃÜËã·¨µÄÒ»ÖÖ£¬µ«ÊÇÇø±ðÔÚÓÚËü²»ÓÃÓÚÄæÔËË㣬ÓÐÒ»¶¨µÄ°²È«ÐÔ¡£ ͨ³£¶ÔÓÚ²»Í¬µÄÓ¦ÓÃϵͳ²ÉÓø÷×ÔÌض¨µÄ¼ø±ðº¯Êý£¬ÕâÑùÔÚÒ»¶¨³Ì¶ÈÉϱ£Ö¤ÁËÊý¾ÝµÄ°²È«ÐÔ¡£
´Ój2sdk1.4ÒÔºó£¬javaÌṩÁËÀàjavax.crypto.MacÀ౨Îļø±ð
byte[] macData = "this is a mac test".getBytes(); //get a instance of Mac, using HmacMD5 algorithm
Mac mac = Mac.getInstance("HmacMD5"); //init the IV of the algorithm, 8 bytes. may read from file
byte[] ivInitKey = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07 };
IvParameterSpec spec = new IvParameterSpec(ivInitKey); // the secrete key bytes of the Mac validation, May read from file too
byte[] keyBytes = { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f }; //generate the secrete Key Object using secrete bytes and DESede algorithm
SecretKey key = new SecretKeySpec(keyBytes, "DESede"); // init Mac mac.init(key, spec);
byte[] macCode = mac.doFinal(macData);
macCode ¾ÍÊÇÉú³ÉµÄMac£¬ÓÃͬÑùµÄÃÜÔ¿ÄܲúÉúͬÑùµÄmac¡£
ͨѶ˫·½Ö»Òª±£Ö¤ÓÃͬÑùµÄÃÜÔ¿¾ÍÄܱ£Ö¤µÃµ½Í¬ÑùµÄMac£¬´ïµ½±¨ÎÄÑéÖ¤µÄÄ¿µÄ¡£
¿´À´¿´È¥£¬ÕâºÍÍøÂçÉϳ£ÓõÄchecksumÔÀíÊÇÒ»ÑùµÄ¡£
ÔÚʵ¼ÊµÄ¿ª·¢ÖУ¬ jvm ĬÈϵÄÄÚ´æ´óСÊDz»¹»µÄ£¬ÐèÒª×Ô¶¨ÒåÉèÖ᣿ɰ´Èçϵķ½·¨½øÐÐÉèÖãº
µÚÒ»¡¢½øÈëµ½Ö¸¶¨ÔËÐÐÎļþµÄ run configurations, ¾Í»áµ¯³öÔËÐÐÉèÖöԻ°´°Ìå
µÚ¶þ¡¢ÔÚ ja ......