cryptix
Class MD5

java.lang.Object
  |
  +--cryptix.MessageDigest
        |
        +--cryptix.MD5

public final class MD5
extends MessageDigest

This class implements the MD5 message digest.

Copyright (C) 1995, 1996 Systemics Ltd (http://www.systemics.com/) All rights reserved.


Field Summary
protected  int[] data
           
static int DATA_LENGTH
           
protected  int[] digest
           
static int HASH_LENGTH
          Length of the final hash (in bytes).
protected  byte[] tmp
           
 
Constructor Summary
MD5()
          The public constructor.
 
Method Summary
static void byte2int(int[] dst, int dst_off, byte[] src, int src_off, int len)
           
static HashMD5 CreateHash(byte[] hash)
          Returns the hash of a single byte array.
 int data_length()
          Return length of the data (in bytes) hashed in every transform.
 MessageHash digestAsHash()
          Returns the digest of the data added and resets the digest.
protected static int F(int x, int y, int z)
           
protected static int FF(int a, int b, int c, int d, int k, int s, int t)
           
protected static int G(int x, int y, int z)
           
static java.lang.String getLinkErrorString()
           
protected static int GG(int a, int b, int c, int d, int k, int s, int t)
           
protected static int H(int x, int y, int z)
           
static boolean hasFileLibraryLoaded()
           
 int hash_length()
          Return length of the hash (in bytes).
static byte[] hash(byte[] msg)
          Returns the hash of a single byte array.
static byte[] hash(java.lang.String msg)
          Returns the hash of a single string.
static HashMD5 hashAsMessageHash(byte[] msg)
          Returns the MessageHash of a single byte array.
static HashMD5 hashAsMessageHash(java.lang.String msg)
          Returns the MessageHash of a single string.
protected static int HH(int a, int b, int c, int d, int k, int s, int t)
           
protected static int I(int x, int y, int z)
           
protected static int II(int a, int b, int c, int d, int k, int s, int t)
           
static boolean isLibraryCorrect()
           
protected  void java_transform()
           
static void main(java.lang.String[] argv)
           
protected  byte[] md_digest()
          Returns the digest of the data added and resets the digest.
 void md_reset()
          Initialise (reset) the message digest.
protected  void md_transform()
          Add data to the message digest
 java.lang.String name()
          Return name of this hash function.
static void self_test(java.io.PrintStream out, java.lang.String[] argv)
           
protected  void transform(int[] M)
           
 
Methods inherited from class cryptix.MessageDigest
add, add, add, add, addToDigest, bitcount, buf_off, buf, digest, hash, hash, length, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HASH_LENGTH

public static final int HASH_LENGTH
Length of the final hash (in bytes).

DATA_LENGTH

public static final int DATA_LENGTH

data

protected int[] data

digest

protected int[] digest

tmp

protected byte[] tmp
Constructor Detail

MD5

public MD5()
The public constructor.
Throws:
UnsatisfiedLinkError - if the library is not of the correct version
Method Detail

hasFileLibraryLoaded

public static final boolean hasFileLibraryLoaded()

isLibraryCorrect

public static final boolean isLibraryCorrect()

getLinkErrorString

public static final java.lang.String getLinkErrorString()

hash_length

public final int hash_length()
Return length of the hash (in bytes).
Overrides:
hash_length in class MessageDigest
Returns:
The length of the hash.
See Also:
HASH_LENGTH

data_length

public final int data_length()
Return length of the data (in bytes) hashed in every transform.
Overrides:
data_length in class MessageDigest
Returns:
The length of the data block.

name

public java.lang.String name()
Return name of this hash function.
Overrides:
name in class MessageDigest
Returns:
The name of the hash function.

md_reset

public void md_reset()
Initialise (reset) the message digest.
Overrides:
md_reset in class MessageDigest

md_transform

protected void md_transform()
Add data to the message digest
Overrides:
md_transform in class MessageDigest
Parameters:
data - The data to be added.
offset - The start of the data in the array.
length - The amount of data to add.

java_transform

protected void java_transform()

md_digest

protected byte[] md_digest()
Returns the digest of the data added and resets the digest.
Overrides:
md_digest in class MessageDigest
Returns:
the digest of all the data added to the message digest as a byte array.

digestAsHash

public MessageHash digestAsHash()
Returns the digest of the data added and resets the digest.
Overrides:
digestAsHash in class MessageDigest
Returns:
the digest of all the data added to the message digest as an object.

hash

public static byte[] hash(java.lang.String msg)
Returns the hash of a single string.
Parameters:
msg - the string to hash.
Returns:
the hash of the string.

hash

public static byte[] hash(byte[] msg)
Returns the hash of a single byte array.
Parameters:
msg - the byte array to hash.
Returns:
the hash of the string.

hashAsMessageHash

public static HashMD5 hashAsMessageHash(java.lang.String msg)
Returns the MessageHash of a single string.
Parameters:
msg - the string to hash.
Returns:
the MessageHash of the string.

hashAsMessageHash

public static HashMD5 hashAsMessageHash(byte[] msg)
Returns the MessageHash of a single byte array.
Parameters:
msg - the byte array to hash.
Returns:
the MessageHash of the byte array.

CreateHash

public static HashMD5 CreateHash(byte[] hash)
Returns the hash of a single byte array.
Parameters:
msg - the byte array to hash.
Returns:
the hash of the string.

F

protected static int F(int x,
                       int y,
                       int z)

G

protected static int G(int x,
                       int y,
                       int z)

H

protected static int H(int x,
                       int y,
                       int z)

I

protected static int I(int x,
                       int y,
                       int z)

FF

protected static int FF(int a,
                        int b,
                        int c,
                        int d,
                        int k,
                        int s,
                        int t)

GG

protected static int GG(int a,
                        int b,
                        int c,
                        int d,
                        int k,
                        int s,
                        int t)

HH

protected static int HH(int a,
                        int b,
                        int c,
                        int d,
                        int k,
                        int s,
                        int t)

II

protected static int II(int a,
                        int b,
                        int c,
                        int d,
                        int k,
                        int s,
                        int t)

transform

protected void transform(int[] M)

byte2int

public static final void byte2int(int[] dst,
                                  int dst_off,
                                  byte[] src,
                                  int src_off,
                                  int len)

main

public static final void main(java.lang.String[] argv)
                       throws java.io.IOException

self_test

public static void self_test(java.io.PrintStream out,
                             java.lang.String[] argv)
                      throws java.lang.Exception