toolbox.security.helper
Class MessageDigestHelper

Package class diagram package MessageDigestHelper
java.lang.Object
  extended by toolbox.security.helper.MessageDigestHelper

public class MessageDigestHelper
extends java.lang.Object

Helper class to perform secure one-way hash operations on arbitrary text values using the java.security.MessageDigest class.


Constructor Summary
MessageDigestHelper()
          Default constructor
 
Method Summary
 java.lang.String digestToBase64(java.lang.String message, java.lang.String algorithm)
          Perform a digest on the given string and return a Base64 representation.
 java.lang.String digestToBase64(java.lang.String message, java.lang.String algorithm, java.lang.String encoding)
          Perform a digest on the given string and return a Base64 representation.
 java.lang.String digestToHex(java.lang.String message, java.lang.String algorithm)
          Perform a digest on the given string and return a hexadecimal representation.
 java.lang.String digestToHex(java.lang.String message, java.lang.String algorithm, java.lang.String encoding)
          Perform a digest on the given string and return a hexadecimal representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageDigestHelper

public MessageDigestHelper()
Default constructor

Method Detail

digestToHex

public java.lang.String digestToHex(java.lang.String message,
                                    java.lang.String algorithm,
                                    java.lang.String encoding)
                             throws java.security.NoSuchAlgorithmException,
                                    java.io.UnsupportedEncodingException
Perform a digest on the given string and return a hexadecimal representation.

Parameters:
message - String containing the data to perform the digest on.
algorithm - String indicating which digest algorithm to use.
encoding - String containing a valid charset name.
Returns:
String containing a hexadecimal representation of the digest.
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

digestToHex

public java.lang.String digestToHex(java.lang.String message,
                                    java.lang.String algorithm)
                             throws java.security.NoSuchAlgorithmException,
                                    java.io.UnsupportedEncodingException
Perform a digest on the given string and return a hexadecimal representation.

Parameters:
message - String containing the data to perform the digest on.
algorithm - String indicating which digest algorithm to use.
Returns:
String containing a hexadecimal representation of the digest.
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

digestToBase64

public java.lang.String digestToBase64(java.lang.String message,
                                       java.lang.String algorithm,
                                       java.lang.String encoding)
                                throws java.security.NoSuchAlgorithmException,
                                       java.io.UnsupportedEncodingException
Perform a digest on the given string and return a Base64 representation.

Parameters:
message - String containing the data to perform the digest on.
algorithm - String indicating which digest algorithm to use.
encoding - String containing a valid charset name.
Returns:
String containing a Base64 representation of the digest.
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

digestToBase64

public java.lang.String digestToBase64(java.lang.String message,
                                       java.lang.String algorithm)
                                throws java.security.NoSuchAlgorithmException,
                                       java.io.UnsupportedEncodingException
Perform a digest on the given string and return a Base64 representation.

Parameters:
message - String containing the data to perform the digest on.
algorithm - String indicating which digest algorithm to use.
Returns:
String containing a Base64 representation of the digest.
Throws:
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException