com.dyuproject.util
Class DigestUtil

java.lang.Object
  extended by com.dyuproject.util.DigestUtil

public final class DigestUtil
extends Object

Util for digesting and encoding bytes/strings.

Author:
David Yu
Date created:
Sep 7, 2008

Field Summary
static byte[] HEXADECIMAL
          The hex chars as bytes.
static String MD5
          "MD5"
static String SHA1
          "SHA-1"
static String SHA256
          "SHA-256"
 
Constructor Summary
DigestUtil()
           
 
Method Summary
static String digestMD5(String data)
          Digests the data with MD5 and returns the raw unencoded bytes.
static String digestMD5(String data, String charset)
          Digests the data with MD5 and the specified charset and returns the raw unencoded bytes.
static String digestSHA1(String data)
          Digests the data with SHA-1 and returns the raw unencoded bytes.
static String digestSHA1(String data, String charset)
          Digests the data with SHA-1 and the specified charset and returns the raw unencoded bytes.
static String digestSHA256(String data)
          Digests the data with SHA-256 and returns the raw unencoded bytes.
static String digestSHA256(String data, String charset)
          Digests the data with SHA-256 and the specified charset and returns the raw unencoded bytes.
static String getDigestedValue(String type, String data)
          Digests the data with the specified type.
static String getDigestedValue(String type, String data, String charset)
          Digests the data with the specified type and charset.
static byte[] getHexBytes(byte[] data)
          Returns the bytes data in hex form.
static char[] getHexChars(byte[] data)
          Returns the bytes data in hex form as characters.
static String getHexString(byte[] data, String charset)
          Returns the bytes data in hex form as string.
static byte[] getPlainDigestedValue(String type, byte[] data)
          Digests the data with the specified type and returns the raw unencoded bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MD5

public static final String MD5
"MD5"

See Also:
Constant Field Values

SHA1

public static final String SHA1
"SHA-1"

See Also:
Constant Field Values

SHA256

public static final String SHA256
"SHA-256"

See Also:
Constant Field Values

HEXADECIMAL

public static final byte[] HEXADECIMAL
The hex chars as bytes.

Constructor Detail

DigestUtil

public DigestUtil()
Method Detail

getHexBytes

public static byte[] getHexBytes(byte[] data)
Returns the bytes data in hex form.


getHexChars

public static char[] getHexChars(byte[] data)
Returns the bytes data in hex form as characters.


getHexString

public static String getHexString(byte[] data,
                                  String charset)
                           throws UnsupportedEncodingException
Returns the bytes data in hex form as string.

Throws:
UnsupportedEncodingException

getDigestedValue

public static String getDigestedValue(String type,
                                      String data,
                                      String charset)
                               throws UnsupportedEncodingException
Digests the data with the specified type and charset.

Throws:
UnsupportedEncodingException

getDigestedValue

public static String getDigestedValue(String type,
                                      String data)
Digests the data with the specified type.


getPlainDigestedValue

public static byte[] getPlainDigestedValue(String type,
                                           byte[] data)
Digests the data with the specified type and returns the raw unencoded bytes.


digestMD5

public static String digestMD5(String data)
Digests the data with MD5 and returns the raw unencoded bytes.


digestMD5

public static String digestMD5(String data,
                               String charset)
Digests the data with MD5 and the specified charset and returns the raw unencoded bytes.


digestSHA1

public static String digestSHA1(String data)
Digests the data with SHA-1 and returns the raw unencoded bytes.


digestSHA1

public static String digestSHA1(String data,
                                String charset)
Digests the data with SHA-1 and the specified charset and returns the raw unencoded bytes.


digestSHA256

public static String digestSHA256(String data)
Digests the data with SHA-256 and returns the raw unencoded bytes.


digestSHA256

public static String digestSHA256(String data,
                                  String charset)
Digests the data with SHA-256 and the specified charset and returns the raw unencoded bytes.



Copyright © 2008-2013. All Rights Reserved.