Implements MD5 functionality on a stream. : MD5 « Security « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Security » MD5Screenshots 
Implements MD5 functionality on a stream.
 
/*
 * Implements MD5 functionality on a stream.
 *
 * written Santeri Paavolainen, Helsinki Finland 1996
 * (c) Santeri Paavolainen, Helsinki Finland 1996
 * modifications Copyright (C) 2002 Stephen Ostermiller
 * http://ostermiller.org/contact.pl?regarding=Java+Utilities
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * See COPYING.TXT for details.
 *
 * The original work by Santeri Paavolainen can be found a
 * http://www.helsinki.fi/~sjpaavol/programs/md5/
 */

import java.io.*;

/**
 * Implements MD5 functionality on a stream.
 * More information about this class is available from <a target="_top" href=
 * "http://ostermiller.org/utils/MD5.html">ostermiller.org</a>.
 * <p>
 * This class produces a 128-bit "fingerprint" or "message digest" for
 * all data written to this stream.
 * It is conjectured that it is computationally infeasible to produce
 * two messages having the same message digest, or to produce any
 * message having a given pre-specified target message digest. The MD5
 * algorithm is intended for digital signature applications, where a
 * large file must be "compressed" in a secure manner before being
 * encrypted with a private (secret) key under a public-key cryptosystem
 * such as RSA.
 * <p>
 * For more information see RFC1321.
 *
 @see MD5
 @see MD5InputStream
 *
 @author Santeri Paavolainen http://www.helsinki.fi/~sjpaavol/programs/md5/
 @author Stephen Ostermiller http://ostermiller.org/contact.pl?regarding=Java+Utilities
 @since ostermillerutils 1.00.00
 */
public class MD5OutputStream extends FilterOutputStream {

  /**
   * MD5 context
   */
  private MD5 md5;

  /**
   * Creates MD5OutputStream
   @param out The output stream
   *
   @since ostermillerutils 1.00.00
   */
  public MD5OutputStream(OutputStream out) {
    super(out);
    md5 = new MD5();
  }

  /**
   * Writes the specified byte to this output stream.
   *
   @param b the byte.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  @Override public void write(int bthrows IOException {
    out.write(b);
    md5.update((byte)(b & 0xff));
  }

  /**
   * Writes length bytes from the specified byte array starting a
   * offset off to this output stream.
   *
   @param b the data.
   @param off the start offset in the data.
   @param len the number of bytes to write.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  @Override public void write(byte b[]int off, int lenthrows IOException {
    out.write(b, off, len);
    md5.update(b, off, len);
  }

  /**
   * Returns array of bytes representing hash of the stream so far.
   *
   @return Array of 16 bytes, the hash of all written bytes.
   *
   @since ostermillerutils 1.00.00
   */
  public byte[] getHash(){
    return md5.getHash();
  }

  /**
   * Get a 32-character hex representation representing hash of the stream so far.
   *
   @return A string containing  the hash of all written bytes.
   *
   @since ostermillerutils 1.00.00
   */
  public String getHashString(){
    return md5.getHashString();
  }
}

class MD5 {

  /**
   * Class constructor
   *
   @since ostermillerutils 1.00.00
   */
  public MD5 () {
    reset();
  }

  /**
   * Command line program that will take files as arguments
   * and output the MD5 sum for each file.
   *
   @param args command line arguments
   *
   @since ostermillerutils 1.00.00
   */
  public static void main (String[] args){
    if (args.length == 0){
      System.err.println("Please specify a file.");
    else {
      for (String element: args) {
        try {
          System.out.println(MD5.getHashString(new File(element)) " " + element);
        catch (IOException x){
          System.err.println(x.getMessage());
        }
      }
    }
  }

  /**
   * Gets this hash sum as an array of 16 bytes.
   *
   @return Array of 16 bytes, the hash of all updated bytes.
   *
   @since ostermillerutils 1.00.00
   */
  public byte[] getHash() {
    if (!finalState.valid) {
      finalState.copy(workingState);
      long bitCount = finalState.bitCount;
      // Compute the number of left over bits
      int leftOver = (int) (((bitCount >>> 3)) 0x3f);
      // Compute the amount of padding to add based on number of left over bits.
      int padlen = (leftOver < 56(56 - leftOver(120 - leftOver);
      // add the padding
      update(finalState, padding, 0, padlen);
      // add the length (computed before padding was added)
      update(finalState, encode(bitCount)08);
      finalState.valid = true;
    }
    // make a copy of the hash before returning it.
    return encode(finalState.state, 16);
  }

  /**
   * Returns 32-character hex representation of this hash.
   *
   @return String representation of this object's hash.
   *
   @since ostermillerutils 1.00.00
   */
  public String getHashString(){
    return toHex(this.getHash());
  }

  /**
   * Gets the MD5 hash of the given byte array.
   *
   @param b byte array for which an MD5 hash is desired.
   @return Array of 16 bytes, the hash of all updated bytes.
   *
   @since ostermillerutils 1.00.00
   */
  public static byte[] getHash(byte[] b){
    MD5 md5 = new MD5();
    md5.update(b);
    return md5.getHash();
  }

  /**
   * Gets the MD5 hash of the given byte array.
   *
   @param b byte array for which an MD5 hash is desired.
   @return 32-character hex representation the data's MD5 hash.
   *
   @since ostermillerutils 1.00.00
   */
  public static String getHashString(byte[] b){
    MD5 md5 = new MD5();
    md5.update(b);
    return md5.getHashString();
  }

  /**
   * Gets the MD5 hash the data on the given InputStream.
   *
   @param in byte array for which an MD5 hash is desired.
   @return Array of 16 bytes, the hash of all updated bytes.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  public static byte[] getHash(InputStream inthrows IOException {
    MD5 md5 = new MD5();
    byte[] buffer = new byte[1024];
    int read;
    while ((read = in.read(buffer)) != -1){
      md5.update(buffer, read);
    }
    return md5.getHash();
  }

  /**
   * Gets the MD5 hash the data on the given InputStream.
   *
   @param in byte array for which an MD5 hash is desired.
   @return 32-character hex representation the data's MD5 hash.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  public static String getHashString(InputStream inthrows IOException {
    MD5 md5 = new MD5();
    byte[] buffer = new byte[1024];
    int read;
    while ((read = in.read(buffer)) != -1){
      md5.update(buffer, read);
    }
    return md5.getHashString();
  }

  /**
   * Gets the MD5 hash of the given file.
   *
   @param f file for which an MD5 hash is desired.
   @return Array of 16 bytes, the hash of all updated bytes.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  public static byte[] getHash(File fthrows IOException {
    InputStream is = new FileInputStream(f);
    byte[] hash = getHash(is);
    is.close();
    return hash;
  }

  /**
   * Gets the MD5 hash of the given file.
   *
   @param f file array for which an MD5 hash is desired.
   @return 32-character hex representation the data's MD5 hash.
   @throws IOException if an I/O error occurs.
   *
   @since ostermillerutils 1.00.00
   */
  public static String getHashString(File fthrows IOException {
    InputStream is = new FileInputStream(f);
    String hash = getHashString(is);
    is.close();
    return hash;
  }

  /**
   * Gets the MD5 hash of the given String.
   * The string is converted to bytes using the current
   * platform's default character encoding.
   *
   @param s String for which an MD5 hash is desired.
   @return Array of 16 bytes, the hash of all updated bytes.
   *
   @since ostermillerutils 1.00.00
   */
  public static byte[] getHash(String s){
    MD5 md5 = new MD5();
    md5.update(s);
    return md5.getHash();
  }

  /**
   * Gets the MD5 hash of the given String.
   * The string is converted to bytes using the current
   * platform's default character encoding.
   *
   @param s String for which an MD5 hash is desired.
   @return 32-character hex representation the data's MD5 hash.
   *
   @since ostermillerutils 1.00.00
   */
  public static String getHashString(String s){
    MD5 md5 = new MD5();
    md5.update(s);
    return md5.getHashString();
  }


  /**
   * Gets the MD5 hash of the given String.
   *
   @param s String for which an MD5 hash is desired.
   @param enc The name of a supported character encoding.
   @return Array of 16 bytes, the hash of all updated bytes.
   @throws UnsupportedEncodingException If the named encoding is not supported.
   *
   @since ostermillerutils 1.00.00
   */
  public static byte[] getHash(String s, String encthrows UnsupportedEncodingException {
    MD5 md5 = new MD5();
    md5.update(s, enc);
    return md5.getHash();
  }

  /**
   * Gets the MD5 hash of the given String.
   *
   @param s String for which an MD5 hash is desired.
   @param enc The name of a supported character encoding.
   @return 32-character hex representation the data's MD5 hash.
   @throws UnsupportedEncodingException If the named encoding is not supported.
   *
   @since ostermillerutils 1.00.00
   */
  public static String getHashString(String s, String encthrows UnsupportedEncodingException {
    MD5 md5 = new MD5();
    md5.update(s, enc);
    return md5.getHashString();
  }


  /**
   * Reset the MD5 sum to its initial state.
   *
   @since ostermillerutils 1.00.00
   */
  public void reset() {
    workingState.reset();
    finalState.valid = false;
  }

  /**
   * Returns 32-character hex representation of this hash.
   *
   @return String representation of this object's hash.
   *
   @since ostermillerutils 1.00.00
   */
  @Override public String toString(){
    return getHashString();
  }

  /**
   * Update this hash with the given data.
   * <p>
   * A state may be passed into this method so that we can add padding
   * and finalize a md5 hash without limiting our ability to update
   * more data later.
   * <p>
   * If length bytes are not available to be hashed, as many bytes as
   * possible will be hashed.
   *
   @param state Which state is updated.
   @param buffer Array of bytes to be hashed.
   @param offset Offset to buffer array.
   @param length number of bytes to hash.
   *
   @since ostermillerutils 1.00.00
   */
  private void update (MD5State state, byte buffer[]int offset, int length) {

    finalState.valid = false;

    // if length goes beyond the end of the buffer, cut it short.
    if ((length + offset> buffer.length){
      length = buffer.length - offset;
    }

    // compute number of bytes mod 64
    // this is what we have sitting in a buffer
    // that have not been hashed yet
    int index = (int) (state.bitCount >>> 30x3f;

    // add the length to the count (translate bytes to bits)
    state.bitCount += length << 3;

    int partlen = 64 - index;

    int i = 0;
    if (length >= partlen) {
      System.arraycopy(buffer, offset, state.buffer, index, partlen);
      transform(state, decode(state.buffer, 640));
      for (i = partlen; (i + 63< length; i+= 64){
        transform(state, decode(buffer, 64, i));
      }
      index = 0;
    }

    // buffer remaining input
    if (i < length) {
      for (int start = i; i < length; i++) {
        state.buffer[index + i - start= buffer[i + offset];
      }
    }
  }

  /**
   * Update this hash with the given data.
   * <p>
   * If length bytes are not available to be hashed, as many bytes as
   * possible will be hashed.
   *
   @param buffer Array of bytes to be hashed.
   @param offset Offset to buffer array.
   @param length number of bytes to hash.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (byte buffer[]int offset, int length) {
    update(workingState, buffer, offset, length);
  }

  /**
   * Update this hash with the given data.
   * <p>
   * If length bytes are not available to be hashed, as many bytes as
   * possible will be hashed.
   *
   @param buffer Array of bytes to be hashed.
   @param length number of bytes to hash.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (byte buffer[]int length) {
    update(buffer, 0, length);
  }

  /**
   * Update this hash with the given data.
   *
   @param buffer Array of bytes to be hashed.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (byte buffer[]) {
    update(buffer, 0, buffer.length);
  }

  /**
   * Updates this hash with a single byte.
   *
   @param b byte to be hashed.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (byte b) {
    byte buffer[] new byte[1];
    buffer[0= b;
    update(buffer, 1);
  }

  /**
   * Update this hash with a String.
   * The string is converted to bytes using the current
   * platform's default character encoding.
   *
   @param s String to be hashed.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (String s) {
    update(s.getBytes());
  }

  /**
   * Update this hash with a String.
   *
   @param s String to be hashed.
   @param enc The name of a supported character encoding.
   @throws UnsupportedEncodingException If the named encoding is not supported.
   *
   @since ostermillerutils 1.00.00
   */
  public void update (String s, String encthrows UnsupportedEncodingException {
    update(s.getBytes(enc));
  }

  /**
   * The current state from which the hash sum
   * can be computed or updated.
   *
   @since ostermillerutils 1.00.00
   */
  private MD5State workingState = new MD5State();

  /**
   * Cached copy of the final MD5 hash sum.  This is created when
   * the hash is requested and it is invalidated when the hash
   * is updated.
   *
   @since ostermillerutils 1.00.00
   */
  private MD5State finalState = new MD5State();

  /**
   * Temporary buffer cached here for performance reasons.
   *
   @since ostermillerutils 1.00.00
   */
  private int[] decodeBuffer = new int[16];

  /**
   * 64 bytes of padding that can be added if the length
   * is not divisible by 64.
   *
   @since ostermillerutils 1.00.00
   */
  private static final byte padding[] {
    (byte0x800000000,
        00000000,
        00000000,
        00000000,
        00000000,
        00000000,
        00000000,
        00000000,
  };

  /**
   * Contains internal state of the MD5 class.
   * Passes MD5 test suite as defined in RFC1321.
   *
   @since ostermillerutils 1.00.00
   */
  private class MD5State {

    /**
     * True if this state is valid.
     *
     @since ostermillerutils 1.00.00
     */
    private boolean valid = true;

    /**
     * Reset to initial state.
     *
     @since ostermillerutils 1.00.00
     */
    private void reset(){
      state[00x67452301;
      state[10xefcdab89;
      state[20x98badcfe;
      state[30x10325476;

      bitCount = 0;
    }

    /**
     * 128-byte state
     *
     @since ostermillerutils 1.00.00
     */
    private int state[] new int[4];

    /**
     * 64-bit count of the number of bits that have been hashed.
     *
     @since ostermillerutils 1.00.00
     */
    private long bitCount;

    /**
     * 64-byte buffer (512 bits) for storing to-be-hashed characters
     *
     @since ostermillerutils 1.00.00
     */
    private byte buffer[] new byte[64];

    private MD5State() {
      reset();
    }

    /**
     * Set this state to be exactly the same as some other.
     *
     @param from state to copy from.
     *
     @since ostermillerutils 1.00.00
     */
    private void copy(MD5State from) {
      System.arraycopy(from.buffer, 0this.buffer, 0this.buffer.length);
      System.arraycopy(from.state, 0this.state, 0this.state.length);
      this.valid = from.valid;
      this.bitCount = from.bitCount;
    }
  }


  /**
   * Turns array of bytes into string representing each byte as
   * a two digit unsigned hex number.
   *
   @param hash Array of bytes to convert to hex-string
   @return  Generated hex string
   *
   @since ostermillerutils 1.00.00
   */
  private static String toHex(byte hash[]){
    StringBuffer buf = new StringBuffer(hash.length * 2);
    for (byte element: hash) {
      int intVal = element & 0xff;
      if (intVal < 0x10){
        // append a zero before a one digit hex
        // number to make it two digits.
        buf.append("0");
      }
      buf.append(Integer.toHexString(intVal));
    }
    return buf.toString();
  }

  private static int FF (int a, int b, int c, int d, int x, int s, int ac) {
    a += ((b & c(~b & d));
    a += x;
    a += ac;
    //return rotateLeft(a, s) + b;
    a = (a << s(a >>> (32 - s));
    return a + b;
  }

  private static int GG (int a, int b, int c, int d, int x, int s, int ac) {
    a += ((b & d(c & ~d));
    a += x;
    a += ac;
    //return rotateLeft(a, s) + b;
    a = (a << s(a >>> (32 - s));
    return a + b;
  }

  private static int HH (int a, int b, int c, int d, int x, int s, int ac) {
    a += (b ^ c ^ d);
    a += x;
    a += ac;
    //return rotateLeft(a, s) + b;
    a = (a << s(a >>> (32 - s));
    return a + b;
  }

  private static int II (int a, int b, int c, int d, int x, int s, int ac) {
    a += (c ^ (b | ~d));
    a += x;
    a += ac;
    //return rotateLeft(a, s) + b;
    a = (a << s(a >>> (32 - s));
    return a + b;
  }

  private static byte[] encode(long l){
    byte[] out = new byte[8];
    out[0(byte) (l & 0xff);
    out[1(byte) ((l >>> 80xff);
    out[2(byte) ((l >>> 160xff);
    out[3(byte) ((l >>> 240xff);
    out[4(byte) ((l >>> 320xff);
    out[5(byte) ((l >>> 400xff);
    out[6(byte) ((l >>> 480xff);
    out[7(byte) ((l >>> 560xff);
    return out;
  }

  private static byte[] encode(int input[]int len){
    byte[] out = new byte[len];
    int i, j;
    for (i = j = 0; j  < len; i++, j += 4) {
      out[j(byte) (input[i0xff);
      out[j + 1(byte) ((input[i>>> 80xff);
      out[j + 2(byte) ((input[i>>> 160xff);
      out[j + 3(byte) ((input[i>>> 240xff);
    }
    return out;
  }

  private int[] decode(byte buffer[]int len, int offset){
    int i, j;
    for (i = j = 0; j < len; i++, j += 4) {
      decodeBuffer[i(
        (buffer[j + offset0xff)) |
        (((buffer[j + + offset0xff)) << 8|
        (((buffer[j + + offset0xff)) << 16|
        (((buffer[j + + offset0xff)) << 24
      );
    }
    return decodeBuffer;
  }

  private static void transform(MD5State state, int[] x){
    int a = state.state[0];
    int b = state.state[1];
    int c = state.state[2];
    int d = state.state[3];

    /* Round 1 */
    a = FF (a, b, c, d, x0],   70xd76aa478)/* 1 */
    d = FF (d, a, b, c, x1],  120xe8c7b756)/* 2 */
    c = FF (c, d, a, b, x2],  170x242070db)/* 3 */
    b = FF (b, c, d, a, x3],  220xc1bdceee)/* 4 */
    a = FF (a, b, c, d, x4],   70xf57c0faf)/* 5 */
    d = FF (d, a, b, c, x5],  120x4787c62a)/* 6 */
    c = FF (c, d, a, b, x6],  170xa8304613)/* 7 */
    b = FF (b, c, d, a, x7],  220xfd469501)/* 8 */
    a = FF (a, b, c, d, x8],   70x698098d8)/* 9 */
    d = FF (d, a, b, c, x9],  120x8b44f7af)/* 10 */
    c = FF (c, d, a, b, x[10],  170xffff5bb1)/* 11 */
    b = FF (b, c, d, a, x[11],  220x895cd7be)/* 12 */
    a = FF (a, b, c, d, x[12],   70x6b901122)/* 13 */
    d = FF (d, a, b, c, x[13],  120xfd987193)/* 14 */
    c = FF (c, d, a, b, x[14],  170xa679438e)/* 15 */
    b = FF (b, c, d, a, x[15],  220x49b40821)/* 16 */

    /* Round 2 */
    a = GG (a, b, c, d, x1],   50xf61e2562)/* 17 */
    d = GG (d, a, b, c, x6],   90xc040b340)/* 18 */
    c = GG (c, d, a, b, x[11],  140x265e5a51)/* 19 */
    b = GG (b, c, d, a, x0],  200xe9b6c7aa)/* 20 */
    a = GG (a, b, c, d, x5],   50xd62f105d)/* 21 */
    d = GG (d, a, b, c, x[10],   90x02441453)/* 22 */
    c = GG (c, d, a, b, x[15],  140xd8a1e681)/* 23 */
    b = GG (b, c, d, a, x4],  200xe7d3fbc8)/* 24 */
    a = GG (a, b, c, d, x9],   50x21e1cde6)/* 25 */
    d = GG (d, a, b, c, x[14],   90xc33707d6)/* 26 */
    c = GG (c, d, a, b, x3],  140xf4d50d87)/* 27 */
    b = GG (b, c, d, a, x8],  200x455a14ed)/* 28 */
    a = GG (a, b, c, d, x[13],   50xa9e3e905)/* 29 */
    d = GG (d, a, b, c, x2],   90xfcefa3f8)/* 30 */
    c = GG (c, d, a, b, x7],  140x676f02d9)/* 31 */
    b = GG (b, c, d, a, x[12],  200x8d2a4c8a)/* 32 */

    /* Round 3 */
    a = HH (a, b, c, d, x5],   40xfffa3942)/* 33 */
    d = HH (d, a, b, c, x8],  110x8771f681)/* 34 */
    c = HH (c, d, a, b, x[11],  160x6d9d6122)/* 35 */
    b = HH (b, c, d, a, x[14],  230xfde5380c)/* 36 */
    a = HH (a, b, c, d, x1],   40xa4beea44)/* 37 */
    d = HH (d, a, b, c, x4],  110x4bdecfa9)/* 38 */
    c = HH (c, d, a, b, x7],  160xf6bb4b60)/* 39 */
    b = HH (b, c, d, a, x[10],  230xbebfbc70)/* 40 */
    a = HH (a, b, c, d, x[13],   40x289b7ec6)/* 41 */
    d = HH (d, a, b, c, x0],  110xeaa127fa)/* 42 */
    c = HH (c, d, a, b, x3],  160xd4ef3085)/* 43 */
    b = HH (b, c, d, a, x6],  230x04881d05)/* 44 */
    a = HH (a, b, c, d, x9],   40xd9d4d039)/* 45 */
    d = HH (d, a, b, c, x[12],  110xe6db99e5)/* 46 */
    c = HH (c, d, a, b, x[15],  160x1fa27cf8)/* 47 */
    b = HH (b, c, d, a, x2],  230xc4ac5665)/* 48 */

    /* Round 4 */
    a = II (a, b, c, d, x0],   60xf4292244)/* 49 */
    d = II (d, a, b, c, x7],  100x432aff97)/* 50 */
    c = II (c, d, a, b, x[14],  150xab9423a7)/* 51 */
    b = II (b, c, d, a, x5],  210xfc93a039)/* 52 */
    a = II (a, b, c, d, x[12],   60x655b59c3)/* 53 */
    d = II (d, a, b, c, x3],  100x8f0ccc92)/* 54 */
    c = II (c, d, a, b, x[10],  150xffeff47d)/* 55 */
    b = II (b, c, d, a, x1],  210x85845dd1)/* 56 */
    a = II (a, b, c, d, x8],   60x6fa87e4f)/* 57 */
    d = II (d, a, b, c, x[15],  100xfe2ce6e0)/* 58 */
    c = II (c, d, a, b, x6],  150xa3014314)/* 59 */
    b = II (b, c, d, a, x[13],  210x4e0811a1)/* 60 */
    a = II (a, b, c, d, x4],   60xf7537e82)/* 61 */
    d = II (d, a, b, c, x[11],  100xbd3af235)/* 62 */
    c = II (c, d, a, b, x2],  150x2ad7d2bb)/* 63 */
    b = II (b, c, d, a, x9],  210xeb86d391)/* 64 */

    state.state[0+= a;
    state.state[1+= b;
    state.state[2+= c;
    state.state[3+= d;
  }
}

   
  
Related examples in the same category
1. OTP one-time password calculationOTP one-time password calculation
2. Applet to serve as an s/key calculator application wrapper around otp class
3. Creating a Keyed Digest Using MD5
4. MD5 BASE64 checksum for the specified input string.
5. MD5 InputStream
6. Fast implementation of RSA's MD5 hash generator in Java JDK Beta-2 or higher
7. MD5 algorithm RFC 1321
8. Contains internal state of the MD5 class
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.