⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 md5.java

📁 基于MJSIP的j2me客户端
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
          (((int) (block[53] & 0xff)) << 8) |
          (((int) (block[54] & 0xff)) << 16) |
          (((int) (block[55])) << 24);
      x[14]=((int)(block[56] & 0xff)) |
          (((int) (block[57] & 0xff)) << 8) |
          (((int) (block[58] & 0xff)) << 16) |
          (((int) (block[59])) << 24);
      x[15]=((int)(block[60] & 0xff)) |
          (((int) (block[61] & 0xff)) << 8) |
          (((int) (block[62] & 0xff)) << 16) |
          (((int) (block[63])) << 24);
                 
      /* Round 1 */
      a+= ((b & c) | (~b & d)) + x[ 0] + 0xd76aa478;
      a = ((a << 7) | (a >>> 25)) + b;
      d+= ((a & b) | (~a & c)) + x[ 1] + 0xe8c7b756;
      d = ((d << 12) | (d >>> 20)) + a;
      c+= ((d & a) | (~d & b)) + x[ 2] + 0x242070db;
      c = ((c << 17) | (c >>> 15)) + d;
      b+= ((c & d) | (~c & a)) + x[ 3] + 0xc1bdceee;
      b = ((b << 22) | (b >>> 10)) + c;
      
      a+= ((b & c) | (~b & d)) + x[ 4] + 0xf57c0faf;
      a = ((a << 7) | (a >>> 25)) + b;
      d+= ((a & b) | (~a & c)) + x[ 5] + 0x4787c62a;
      d = ((d << 12) | (d >>> 20)) + a;
      c+= ((d & a) | (~d & b)) + x[ 6] + 0xa8304613;
      c = ((c << 17) | (c >>> 15)) + d;
      b+= ((c & d) | (~c & a)) + x[ 7] + 0xfd469501;
      b = ((b << 22) | (b >>> 10)) + c;
      
      a+= ((b & c) | (~b & d)) + x[ 8] + 0x698098d8;
      a = ((a << 7) | (a >>> 25)) + b;
      d+= ((a & b) | (~a & c)) + x[ 9] + 0x8b44f7af;
      d = ((d << 12) | (d >>> 20)) + a;
      c+= ((d & a) | (~d & b)) + x[10] + 0xffff5bb1;
      c = ((c << 17) | (c >>> 15)) + d;
      b+= ((c & d) | (~c & a)) + x[11] + 0x895cd7be;
      b = ((b << 22) | (b >>> 10)) + c;
      
      a+= ((b & c) | (~b & d)) + x[12] + 0x6b901122;
      a = ((a << 7) | (a >>> 25)) + b;
      d+= ((a & b) | (~a & c)) + x[13] + 0xfd987193;
      d = ((d << 12) | (d >>> 20)) + a;
      c+= ((d & a) | (~d & b)) + x[14] + 0xa679438e;
      c = ((c << 17) | (c >>> 15)) + d;
      b+= ((c & d) | (~c & a)) + x[15] + 0x49b40821;
      b = ((b << 22) | (b >>> 10)) + c;
      
      
      /* Round 2 */
      a+= ((b & d) | (c & ~d)) + x[ 1] + 0xf61e2562;
      a = ((a << 5) | (a >>> 27)) + b;
      d+= ((a & c) | (b & ~c)) + x[ 6] + 0xc040b340;
      d = ((d << 9) | (d >>> 23)) + a;
      c+= ((d & b) | (a & ~b)) + x[11] + 0x265e5a51;
      c = ((c << 14) | (c >>> 18)) + d;
      b+= ((c & a) | (d & ~a)) + x[ 0] + 0xe9b6c7aa;
      b = ((b << 20) | (b >>> 12)) + c;
      
      a+= ((b & d) | (c & ~d)) + x[ 5] + 0xd62f105d;
      a = ((a << 5) | (a >>> 27)) + b;
      d+= ((a & c) | (b & ~c)) + x[10] + 0x02441453;
      d = ((d << 9) | (d >>> 23)) + a;
      c+= ((d & b) | (a & ~b)) + x[15] + 0xd8a1e681;
      c = ((c << 14) | (c >>> 18)) + d;
      b+= ((c & a) | (d & ~a)) + x[ 4] + 0xe7d3fbc8;
      b = ((b << 20) | (b >>> 12)) + c;
      
      a+= ((b & d) | (c & ~d)) + x[ 9] + 0x21e1cde6;
      a = ((a << 5) | (a >>> 27)) + b;
      d+= ((a & c) | (b & ~c)) + x[14] + 0xc33707d6;
      d = ((d << 9) | (d >>> 23)) + a;
      c+= ((d & b) | (a & ~b)) + x[ 3] + 0xf4d50d87;
      c = ((c << 14) | (c >>> 18)) + d;
      b+= ((c & a) | (d & ~a)) + x[ 8] + 0x455a14ed;
      b = ((b << 20) | (b >>> 12)) + c;
      
      a+= ((b & d) | (c & ~d)) + x[13] + 0xa9e3e905;
      a = ((a << 5) | (a >>> 27)) + b;
      d+= ((a & c) | (b & ~c)) + x[ 2] + 0xfcefa3f8;
      d = ((d << 9) | (d >>> 23)) + a;
      c+= ((d & b) | (a & ~b)) + x[ 7] + 0x676f02d9;
      c = ((c << 14) | (c >>> 18)) + d;
      b+= ((c & a) | (d & ~a)) + x[12] + 0x8d2a4c8a;
      b = ((b << 20) | (b >>> 12)) + c;
      
      
      /* Round 3 */
      a+= (b ^ c ^ d) + x[ 5] + 0xfffa3942;
      a = ((a << 4) | (a >>> 28)) + b;
      d+= (a ^ b ^ c) + x[ 8] + 0x8771f681;
      d = ((d << 11) | (d >>> 21)) + a;
      c+= (d ^ a ^ b) + x[11] + 0x6d9d6122;
      c = ((c << 16) | (c >>> 16)) + d;
      b+= (c ^ d ^ a) + x[14] + 0xfde5380c;
      b = ((b << 23) | (b >>> 9)) + c;
      
      a+= (b ^ c ^ d) + x[ 1] + 0xa4beea44;
      a = ((a << 4) | (a >>> 28)) + b;
      d+= (a ^ b ^ c) + x[ 4] + 0x4bdecfa9;
      d = ((d << 11) | (d >>> 21)) + a;
      c+= (d ^ a ^ b) + x[ 7] + 0xf6bb4b60;
      c = ((c << 16) | (c >>> 16)) + d;
      b+= (c ^ d ^ a) + x[10] + 0xbebfbc70;
      b = ((b << 23) | (b >>> 9)) + c;
      
      a+= (b ^ c ^ d) + x[13] + 0x289b7ec6;
      a = ((a << 4) | (a >>> 28)) + b;
      d+= (a ^ b ^ c) + x[ 0] + 0xeaa127fa;
      d = ((d << 11) | (d >>> 21)) + a;
      c+= (d ^ a ^ b) + x[ 3] + 0xd4ef3085;
      c = ((c << 16) | (c >>> 16)) + d;
      b+= (c ^ d ^ a) + x[ 6] + 0x04881d05;
      b = ((b << 23) | (b >>> 9)) + c;
      
      a+= (b ^ c ^ d) + x[ 9] + 0xd9d4d039;
      a = ((a << 4) | (a >>> 28)) + b;
      d+= (a ^ b ^ c) + x[12] + 0xe6db99e5;
      d = ((d << 11) | (d >>> 21)) + a;
      c+= (d ^ a ^ b) + x[15] + 0x1fa27cf8;
      c = ((c << 16) | (c >>> 16)) + d;
      b+= (c ^ d ^ a) + x[ 2] + 0xc4ac5665;
      b = ((b << 23) | (b >>> 9)) + c;
      
      
      /* Round 4 */
      a+= (c ^ (b | ~d)) + x[ 0] + 0xf4292244;
      a = ((a << 6) | (a >>> 26)) + b;
      d+= (b ^ (a | ~c)) + x[ 7] + 0x432aff97;
      d = ((d << 10) | (d >>> 22)) + a;
      c+= (a ^ (d | ~b)) + x[14] + 0xab9423a7;
      c = ((c << 15) | (c >>> 17)) + d;
      b+= (d ^ (c | ~a)) + x[ 5] + 0xfc93a039;
      b = ((b << 21) | (b >>> 11)) + c;
      
      a+= (c ^ (b | ~d)) + x[12] + 0x655b59c3;
      a = ((a << 6) | (a >>> 26)) + b;
      d+= (b ^ (a | ~c)) + x[ 3] + 0x8f0ccc92;
      d = ((d << 10) | (d >>> 22)) + a;
      c+= (a ^ (d | ~b)) + x[10] + 0xffeff47d;
      c = ((c << 15) | (c >>> 17)) + d;
      b+= (d ^ (c | ~a)) + x[ 1] + 0x85845dd1;
      b = ((b << 21) | (b >>> 11)) + c;
      
      a+= (c ^ (b | ~d)) + x[ 8] + 0x6fa87e4f;
      a = ((a << 6) | (a >>> 26)) + b;
      d+= (b ^ (a | ~c)) + x[15] + 0xfe2ce6e0;
      d = ((d << 10) | (d >>> 22)) + a;
      c+= (a ^ (d | ~b)) + x[ 6] + 0xa3014314;
      c = ((c << 15) | (c >>> 17)) + d;
      b+= (d ^ (c | ~a)) + x[13] + 0x4e0811a1;
      b = ((b << 21) | (b >>> 11)) + c;
      
      a+= (c ^ (b | ~d)) + x[ 4] + 0xf7537e82;
      a = ((a << 6) | (a >>> 26)) + b;
      d+= (b ^ (a | ~c)) + x[11] + 0xbd3af235;
      d = ((d << 10) | (d >>> 22)) + a;
      c+= (a ^ (d | ~b)) + x[ 2] + 0x2ad7d2bb;
      c = ((c << 15) | (c >>> 17)) + d;
      b+= (d ^ (c | ~a)) + x[ 9] + 0xeb86d391;
      b = ((b << 21) | (b >>> 11)) + c;
      
      state[0]+= a;
      state[1]+= b;
      state[2]+= c;
      state[3]+= d;
   }


   /** F MD5 function. */
   //private static int F(int x, int y, int z) {  return (x & y) | ((~x) & z);  }
   /** G MD5 function. */
   //private static int G(int x, int y, int z) {  return (x & z) | (y & (~z));  }
   /** H MD5 function. */
   //private static int H(int x, int y, int z) {  return (x ^ y ^ z);  }
   /** I MD5 function. */
   //private static int I(int x, int y, int z) {  return y ^ (x | (~z));  }


   /** FF transformation for round 1.
       Rotation is separate from addition to prevent recomputation. */
   /*private static int[] FF(int[] w, int x, int s, int t)
   {  w[0] += F(w[1],w[2],w[3]) + x + t;
      w[0] = rotateLeft(w[0],s) + w[1];
      return rotateLeft(w);
   }*/
   /** GG transformation for round 2.
       Rotation is separate from addition to prevent recomputation. */
   /*private static int[] GG(int[] w, int x, int s, int t)
   {  w[0] += G(w[1],w[2],w[3]) + x + t;
      w[0] = rotateLeft(w[0],s) + w[1];
      return rotateLeft(w);
   }*
   /** HH transformation for round 3.
       Rotation is separate from addition to prevent recomputation. */
   /*private static int[] HH(int[] w, int x, int s, int t)
   {  w[0] += H(w[1],w[2],w[3]) + x + t;
      w[0] = rotateLeft(w[0],s) + w[1];
      return rotateLeft(w);
   }*
   /** II transformation for round 4.
       Rotation is separate from addition to prevent recomputation. */
   /*private static int[] II(int[] w, int x, int s, int t)
   {  w[0] += I(w[1],w[2],w[3]) + x + t;
      w[0] = rotateLeft(w[0],s) + w[1];
      return rotateLeft(w);
   }*/


   /** MD5 basic transformation. Transforms state based on block. */
   /*private static void transform(int[] state, byte[] block)
   {
      int[] x=new int[16];
      for (int i=0; i<16; i++) x[i]=(int)bytesToWord(block,(i*4));
      
      // make a copy of the state
      int[] state_cp=new int[4];
      for (int i=0; i<4; i++) state_cp[i]=state[i];
      
      // Round 1
      FF (state, x[ 0], S11, 0xd76aa478); 
      FF (state, x[ 1], S12, 0xe8c7b756);
      FF (state, x[ 2], S13, 0x242070db);
      FF (state, x[ 3], S14, 0xc1bdceee);
      FF (state, x[ 4], S11, 0xf57c0faf);
      FF (state, x[ 5], S12, 0x4787c62a);
      FF (state, x[ 6], S13, 0xa8304613);
      FF (state, x[ 7], S14, 0xfd469501);
      FF (state, x[ 8], S11, 0x698098d8);
      FF (state, x[ 9], S12, 0x8b44f7af);
      FF (state, x[10], S13, 0xffff5bb1);
      FF (state, x[11], S14, 0x895cd7be);
      FF (state, x[12], S11, 0x6b901122);
      FF (state, x[13], S12, 0xfd987193);
      FF (state, x[14], S13, 0xa679438e);
      FF (state, x[15], S14, 0x49b40821);

      // Round 2
      GG (state, x[ 1], S21, 0xf61e2562);
      GG (state, x[ 6], S22, 0xc040b340);
      GG (state, x[11], S23, 0x265e5a51);
      GG (state, x[ 0], S24, 0xe9b6c7aa);
      GG (state, x[ 5], S21, 0xd62f105d);
      GG (state, x[10], S22,  0x2441453);
      GG (state, x[15], S23, 0xd8a1e681);
      GG (state, x[ 4], S24, 0xe7d3fbc8);
      GG (state, x[ 9], S21, 0x21e1cde6);
      GG (state, x[14], S22, 0xc33707d6);
      GG (state, x[ 3], S23, 0xf4d50d87);
      GG (state, x[ 8], S24, 0x455a14ed);
      GG (state, x[13], S21, 0xa9e3e905);
      GG (state, x[ 2], S22, 0xfcefa3f8);
      GG (state, x[ 7], S23, 0x676f02d9);
      GG (state, x[12], S24, 0x8d2a4c8a);

      // Round 3
      HH (state, x[ 5], S31, 0xfffa3942);
      HH (state, x[ 8], S32, 0x8771f681);
      HH (state, x[11], S33, 0x6d9d6122);
      HH (state, x[14], S34, 0xfde5380c);
      HH (state, x[ 1], S31, 0xa4beea44);
      HH (state, x[ 4], S32, 0x4bdecfa9);
      HH (state, x[ 7], S33, 0xf6bb4b60);
      HH (state, x[10], S34, 0xbebfbc70);
      HH (state, x[13], S31, 0x289b7ec6);
      HH (state, x[ 0], S32, 0xeaa127fa);
      HH (state, x[ 3], S33, 0xd4ef3085);
      HH (state, x[ 6], S34,  0x4881d05);
      HH (state, x[ 9], S31, 0xd9d4d039);
      HH (state, x[12], S32, 0xe6db99e5);
      HH (state, x[15], S33, 0x1fa27cf8);
      HH (state, x[ 2], S34, 0xc4ac5665);

      // Round 4
      II (state, x[ 0], S41, 0xf4292244);
      II (state, x[ 7], S42, 0x432aff97);
      II (state, x[14], S43, 0xab9423a7);
      II (state, x[ 5], S44, 0xfc93a039);
      II (state, x[12], S41, 0x655b59c3);
      II (state, x[ 3], S42, 0x8f0ccc92);
      II (state, x[10], S43, 0xffeff47d);
      II (state, x[ 1], S44, 0x85845dd1);
      II (state, x[ 8], S41, 0x6fa87e4f);
      II (state, x[15], S42, 0xfe2ce6e0);
      II (state, x[ 6], S43, 0xa3014314);
      II (state, x[13], S44, 0x4e0811a1);
      II (state, x[ 4], S41, 0xf7537e82);
      II (state, x[11], S42, 0xbd3af235);
      II (state, x[ 2], S43, 0x2ad7d2bb);
      II (state, x[ 9], S44, 0xeb86d391);
      
      for (int i=0; i<4; i++) state[i]+=state_cp[i];
   }*/


   
   /** Calculates the MD5. */
   public static byte[] digest(byte[] buffer, int offset, int len)
   {  MD5 md5=new MD5(buffer,offset,len);
      return md5.doFinal();
   }


   /** Calculates the MD5. */
   public static byte[] digest(byte[] buffer)
   {  return digest(buffer,0,buffer.length);
   }


   /** Calculates the MD5. */
   public static byte[] digest(String str)
   {  MD5 md5=new MD5(str);
      return md5.doFinal();
   }
   
   
   /** Gets the message-digest as string of hex values */
   /*public String asHex()
   {   return asHex(doFinal());
   }*/


   /** Transforms an array of bytes into a string of hex values */
   /*public static String asHex(byte[] buf)
   {  String str=new String();
      for (int i=0; i<buf.length; i++)
      {  str+=Integer.toHexString((buf[i]>>>4)&0x0F);
         str+=Integer.toHexString(buf[i]&0x0F);
      }
      return str;
   }*/

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -