Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

JavaÖеÄmac¼ÆËã

          ±¨Îļø±ðÔÚÉí·ÝÈÏÖ¤ÖÐÕ¼ÖØҪλÖã¬ÊÇÈÏ֤ϵͳµÄÒ»¸öÖØÒª»·½Ú£¬ÔÚ½ðÈÚºÍÉÌҵϵͳÖй㷺ӦÓá£
          ±¨Îļø±ð³£Óñ¨Îļø±ðÂ루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Ô­ÀíÊÇÒ»ÑùµÄ¡£


Ïà¹ØÎĵµ£º

java±ÊÊÔ

1.MVCµÄ¸÷¸ö²¿·Ö¶¼ÓÐÄÇЩ¼¼ÊõÀ´ÊµÏÖ?ÈçºÎʵÏÖ?
´ð£ºMVCÊÇModel£­View£­ControllerµÄ¼òд¡£"Model" ´ú±íµÄÊÇÓ¦ÓõÄÒµÎñÂß¼­£¨Í¨¹ýJavaBean£¬EJB×é¼þʵÏÖ£©£¬ "View" ÊÇÓ¦ÓõıíʾÃ棨ÓÉJSPÒ³Ãæ²úÉú£©£¬"Controller" ÊÇÌṩӦÓõĴ¦Àí¹ý³Ì¿ØÖÆ£¨Ò»°ãÊÇÒ»¸öServlet£©£¬Í¨¹ýÕâÖÖÉè¼ÆÄ£ÐÍ°ÑÓ¦ÓÃÂß¼­£¬´¦Àí¹ý³ÌºÍÏÔʾÂß¼­·Ö³É²» ......

Java SE Static Inner

/*ÄÚ²¿ÀàʹÓÃʾÀý*/
package demo;
class Outer{
 int outer_i=100;
 static int outer_j=200;
 final int outer_k=300;
 void test(){
  Inner in = new Inner();
  in.display();
 }
 static class Inner{
  void display(){
    ......

ÔÚ Eclipse ÖÐÉèÖà java ÐéÄâ»úÄÚ´æµÄ·½·¨

        ÔÚʵ¼ÊµÄ¿ª·¢ÖУ¬ jvm ĬÈϵÄÄÚ´æ´óСÊDz»¹»µÄ£¬ÐèÒª×Ô¶¨ÒåÉèÖ᣿ɰ´Èçϵķ½·¨½øÐÐÉèÖãº
        µÚÒ»¡¢½øÈëµ½Ö¸¶¨ÔËÐÐÎļþµÄ run configurations, ¾Í»áµ¯³öÔËÐÐÉèÖöԻ°´°Ìå
        µÚ¶þ¡¢ÔÚ ja ......

java±£ÁôÁ½Î»Ð¡Êý

/**
   * ±£ÁôÁ½Î»Ð¡Êý
   * @param d
   * @return
   */
  private static double remainTwoNumbers(double d){
    java.math.BigDecimal   f1   =   new   java.math.BigDecimal(d);//СÊýµãºó±£Áô2Î ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ