Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 ´òÓ¡ÁâÐÎ

public class testthree {
 public static void main(String[] args) {
  testthree t = new testthree();
  t.test();
 }
 private static void test() {
  int d = 0;
  int f = 4;
  int x = 0;
  int y = 6;
  for (i ......

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(){
    ......

Java SE ÄÚ²¿ÀàÓ뾲̬±äÁ¿

package demo;
class InOut{
 String str=new String("Between");
 static int i=666;
  int j=888;
  final int k=999;
 public void amethod(final int iArgs){
  int it315;
  final int x=111;
 /*static*/ class Bicycle
  { 
//&n ......

Javaѧϰ£¬Ï£ÍûÅóÓÑÃǽ»Á÷Ö¸µ¼£¡

¸øÊý×鸳ֵµÄ±ã½Ý·½Ê½£º String s=reader.nextLine();    char a[]=s.toCharArray();ÕâÑù¾Í²»ÓÃʹÓÃÂé·³µÄforÑ­»·À´¸³ÖµÁË
        Êä³öÊý×éÄÚÈݵıã½Ý·½Ê½£ºString code=new String(a); //aÊÇÒ»¸öÊý×éÃû
   System.out.println("Ô­ÎÄÊÇ"+code);
 &nb ......

java³£ÓÃʵÓÃÀàѧϰ11.29

ÏÖÔÚ ËùÓÃJava°æ±¾,DateÀ๹Ôì·½·¨Date(0)µÄʱ¼ä²»ÊÇThu Jan 01 01:00:00 GMT 1970ÁË£¬¶øÊÇThu Jan 01 08:00:00 CST 1970¡££¨ 1970 Äê1 ÔÂ1 ÈÕ8ʱ0·Ö0Ãë ÐÇÆÚ4£©
     Ϊʲô Date b1=new Date(623289600000); ²»¿ÉÒÔ£¬ÏÂÃæµÄÈ´¿ÉÒÔÄØ£¿
long a=623289600000L;
   Date b1=new Date(a); Ò ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ