All Packages  This Package  Class Hierarchy  Class Search  Index

Class edu.utah.janos.antsr.util.MD5
java.lang.Object
   |
   +----edu.utah.janos.antsr.util.MD5

  Summary

public final class  MD5
     extends java.lang.Object
{
          // Fields 5
     private final byte[] buffer;
     private final int[] count;
     private static final byte[] padding;
     private final int[] state;
     private final int[] tx;

          // Constructors 1
     public MD5();

          // Methods 15
     private static int FF(int, int, int, int, int, int, int);
     private static int GG(int, int, int, int, int, int, int);
     private static int HH(int, int, int, int, int, int, int);
     private static int II(int, int, int, int, int, int, int);
     public static byte[] hash(byte[]);
     public static byte[] hash(byte[], int, int);
     private static byte[] ints2bytes(int[]);
     private static int rotleft(int, int);
     public static String toShortString(byte[]);
     public static String toString(byte[]);

     public byte[] hash();
     private void transform(byte[], int);
     public void update(byte[]);
     public void update(byte[], int, int);
     public void update(String);
}

Implementation of RSA's MD5 hash generator

This code is loosely based on the RSA reference implementation and an early Java port of it by Santeri Paavolainen.

Objects of this class are single use only -- clients must ensure that only one hash is computed, and sequentially too. Hashes are returned as an array of 16 bytes.

Usage:

   byte[] hash = MD5.hash(bytes);   // single pass mode
 
or
   MD5 digest = new MD5();          // multiple pass mode
   digest.update(bytes);
   digest.update(morebytes);
   byte[] hash = digest.hash();
 

(Pat) Optimizations: combine all of the arrays into a single array and use fixed offsets.

Author:
David Wetherall




  Fields

· state

Summary  |  Top

   private final int[] state

128-bit state


· tx

Summary  |  Top
   private final int[] tx

64-byte transform pass


· count

Summary  |  Top
   private final int[] count

64-bit character count


· buffer

Summary  |  Top
   private final byte[] buffer

64-byte overflow buffer


· padding

Summary  |  Top
   private static final byte[] padding


  Constructors

· MD5

Summary  |  Top

   public MD5() 


  Methods

· rotleft

Summary  |  Top
   private static int rotleft(int x, 
                              int n) 


· FF

Summary  |  Top
   private static int FF(int a, 
                         int b, 
                         int c, 
                         int d, 
                         int x, 
                         int s, 
                         int ac) 


· GG

Summary  |  Top
   private static int GG(int a, 
                         int b, 
                         int c, 
                         int d, 
                         int x, 
                         int s, 
                         int ac) 


· HH

Summary  |  Top
   private static int HH(int a, 
                         int b, 
                         int c, 
                         int d, 
                         int x, 
                         int s, 
                         int ac) 


· II

Summary  |  Top
   private static int II(int a, 
                         int b, 
                         int c, 
                         int d, 
                         int x, 
                         int s, 
                         int ac) 


· transform

Summary  |  Top
   private void transform(byte[] buf, 
                          int shift) 


· update

Summary  |  Top
   public void update(byte[] buf, 
                      int offset, 
                      int length) 


· update

Summary  |  Top
   public void update(byte[] buf) 


· update

Summary  |  Top
   public void update(String s) 


· ints2bytes

Summary  |  Top
   private static byte[] ints2bytes(int[] input) 


· hash

Summary  |  Top
   public byte[] hash() 


· hash

Summary  |  Top
   public static byte[] hash(byte[] buf, 
                             int off, 
                             int len) 


· hash

Summary  |  Top
   public static byte[] hash(byte[] buf) 


· toString

Summary  |  Top
   public static String toString(byte[] hash) 


· toShortString

Summary  |  Top
   public static String toShortString(byte[] hash) 


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7