org.jopendocument.util
Class MessageDigestUtils

java.lang.Object
  extended by org.jopendocument.util.MessageDigestUtils

public class MessageDigestUtils
extends java.lang.Object


Method Summary
static java.lang.String asHex(byte[] hash)
          Turns array of bytes into string representing each byte as unsigned hex number.
static int bytes2int(byte[] buf)
          Cat 4 bytes to make an int.
static byte[] fromHex(java.lang.String hash)
           
static java.lang.String getHashString(java.security.MessageDigest md)
           
static java.lang.String getHashString(java.security.MessageDigest md, byte[] data)
           
static java.lang.String getHashString(java.security.MessageDigest md, java.io.InputStream ins)
           
static java.lang.String getHashString(java.lang.String algo, byte[] data)
           
static java.security.MessageDigest getMD5()
           
static java.lang.String getMD5(java.io.File f)
           
static byte[] int2bytes(int integer)
          Split an int into 4 bytes.
static java.lang.String toString(byte[] hash, char[] chars)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

asHex

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

Parameters:
hash - Array of bytes to convert to hex-string
Returns:
Generated hex string

toString

public static java.lang.String toString(byte[] hash,
                                        char[] chars)

fromHex

public static byte[] fromHex(java.lang.String hash)

int2bytes

public static byte[] int2bytes(int integer)
Split an int into 4 bytes.

Parameters:
integer - an int, eg -2^31, or 16.
Returns:
the 4 bytes of its two's complement, eg [0x80, 0x00, 0x00, 0x00] or [0x00, 0x00, 0x00, 0x10].

bytes2int

public static int bytes2int(byte[] buf)
Cat 4 bytes to make an int.

Parameters:
buf - an array of at least 4 bytes, eg [0x80, 0x00, 0x00, 0x03].
Returns:
the resulting int, eg -2^31 + 3 or -2147483645.

getHashString

public static java.lang.String getHashString(java.security.MessageDigest md)

getHashString

public static java.lang.String getHashString(java.lang.String algo,
                                             byte[] data)
                                      throws java.security.NoSuchAlgorithmException
Throws:
java.security.NoSuchAlgorithmException

getHashString

public static java.lang.String getHashString(java.security.MessageDigest md,
                                             byte[] data)

getHashString

public static java.lang.String getHashString(java.security.MessageDigest md,
                                             java.io.InputStream ins)
                                      throws java.io.IOException
Throws:
java.io.IOException

getMD5

public static java.lang.String getMD5(java.io.File f)
                               throws java.io.IOException
Throws:
java.io.IOException

getMD5

public static java.security.MessageDigest getMD5()