org.jopendocument.util
Class MessageDigestUtils

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

public class MessageDigestUtils
extends Object


Method Summary
static 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(String hash)
           
static String getHashString(MessageDigest md)
           
static String getHashString(MessageDigest md, byte[] data)
           
static String getHashString(MessageDigest md, InputStream ins)
           
static String getHashString(String algo, byte[] data)
           
static MessageDigest getMD5()
           
static String getMD5(File f)
           
static byte[] int2bytes(int integer)
          Split an int into 4 bytes.
static String toString(byte[] hash, char[] chars)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

asHex

public static 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 String toString(byte[] hash,
                              char[] chars)

fromHex

public static byte[] fromHex(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 String getHashString(MessageDigest md)

getHashString

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

getHashString

public static String getHashString(MessageDigest md,
                                   byte[] data)

getHashString

public static String getHashString(MessageDigest md,
                                   InputStream ins)
                            throws IOException
Throws:
IOException

getMD5

public static String getMD5(File f)
                     throws IOException
Throws:
IOException

getMD5

public static MessageDigest getMD5()


Copyright © 2010 jOpenDocument All Rights Reserved.