Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

plugins.MsnEngine
Class MD5  view MD5 download MD5.java

java.lang.Object
  extended byplugins.MsnEngine.MD5

public class MD5
extends java.lang.Object

Implementation of RSA's MD5 hash generator

Version:
$Revision: 1.3 $

Nested Class Summary
private  class MD5.MD5State
          Contains internal state of the MD5 class
 
Field Summary
(package private)  MD5.MD5State finals
          If Final() has been called, finals is set to the current finals state.
(package private) static byte[] padding
          Padding for Final()
(package private)  MD5.MD5State state
          MD5 state
 
Constructor Summary
MD5()
          Class constructor
MD5(java.lang.Object ob)
          Initialize class, and update hash with ob.toString()
 
Method Summary
 java.lang.String asHex()
          Returns 32-character hex representation of this objects hash
static java.lang.String asHex(byte[] hash)
          Turns array of bytes into string representing each byte as unsigned hex number.
private  int[] Decode(byte[] buffer, int len, int shift)
           
private  byte[] Encode(int[] input, int len)
           
private  int FF(int a, int b, int c, int d, int x, int s, int ac)
           
 byte[] Final()
          Returns array of bytes (16 bytes) representing hash as of the current state of this object.
private  int GG(int a, int b, int c, int d, int x, int s, int ac)
           
private  int HH(int a, int b, int c, int d, int x, int s, int ac)
           
private  int II(int a, int b, int c, int d, int x, int s, int ac)
           
 void Init()
          Initialize MD5 internal state (object can be reused just by calling Init() after every Final()
private  int rotate_left(int x, int n)
           
private  void Transform(MD5.MD5State state, byte[] buffer, int shift)
           
private  int uadd(int a, int b)
           
private  int uadd(int a, int b, int c)
           
private  int uadd(int a, int b, int c, int d)
           
 void Update(byte b)
          Updates hash with a single byte
 void Update(byte[] buffer)
          Updates hash with given array of bytes
 void Update(byte[] buffer, int length)
           
 void Update(byte[] buffer, int offset, int length)
          Plain update, updates this object
 void Update(int i)
          Update buffer with a single integer (only & 0xff part is used, as a byte)
 void Update(MD5.MD5State stat, byte[] buffer, int offset, int length)
          Updates hash with the bytebuffer given (using at maximum length bytes from that buffer)
 void Update(java.lang.String s)
          Update buffer with given string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

state

MD5.MD5State state
MD5 state


finals

MD5.MD5State finals
If Final() has been called, finals is set to the current finals state. Any Update() causes this to be set to null.


padding

static byte[] padding
Padding for Final()

Constructor Detail

MD5

public MD5()
Class constructor


MD5

public MD5(java.lang.Object ob)
Initialize class, and update hash with ob.toString()

Method Detail

Init

public void Init()
Initialize MD5 internal state (object can be reused just by calling Init() after every Final()


rotate_left

private int rotate_left(int x,
                        int n)

uadd

private int uadd(int a,
                 int b)

uadd

private int uadd(int a,
                 int b,
                 int c)

uadd

private int uadd(int a,
                 int b,
                 int c,
                 int d)

FF

private int FF(int a,
               int b,
               int c,
               int d,
               int x,
               int s,
               int ac)

GG

private int GG(int a,
               int b,
               int c,
               int d,
               int x,
               int s,
               int ac)

HH

private int HH(int a,
               int b,
               int c,
               int d,
               int x,
               int s,
               int ac)

II

private int II(int a,
               int b,
               int c,
               int d,
               int x,
               int s,
               int ac)

Decode

private int[] Decode(byte[] buffer,
                     int len,
                     int shift)

Transform

private void Transform(MD5.MD5State state,
                       byte[] buffer,
                       int shift)

Update

public void Update(MD5.MD5State stat,
                   byte[] buffer,
                   int offset,
                   int length)
Updates hash with the bytebuffer given (using at maximum length bytes from that buffer)


Update

public void Update(byte[] buffer,
                   int offset,
                   int length)
Plain update, updates this object


Update

public void Update(byte[] buffer,
                   int length)

Update

public void Update(byte[] buffer)
Updates hash with given array of bytes


Update

public void Update(byte b)
Updates hash with a single byte


Update

public void Update(java.lang.String s)
Update buffer with given string.


Update

public void Update(int i)
Update buffer with a single integer (only & 0xff part is used, as a byte)


Encode

private byte[] Encode(int[] input,
                      int len)

Final

public byte[] Final()
Returns array of bytes (16 bytes) representing hash as of the current state of this object. Note: getting a hash does not invalidate the hash object, it only creates a copy of the real state which is finalized.


asHex

public static java.lang.String asHex(byte[] hash)
Turns array of bytes into string representing each byte as unsigned hex number.


asHex

public java.lang.String asHex()
Returns 32-character hex representation of this objects hash