Class HashUtils

java.lang.Object
com.castlabs.utils.HashUtils

public class HashUtils extends Object
Utility hash functions
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    decodeHex(char[] data)
    Converts an array of character bytes representing hexadecimal values into an array of bytes of those same values.
    static String
    md5(String source)
    Takes a string and returns the HEX representation of the MD5 sum for the given string.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HashUtils

      public HashUtils()
  • Method Details

    • md5

      public static String md5(String source)
      Takes a string and returns the HEX representation of the MD5 sum for the given string.
      Parameters:
      source - the string
      Returns:
      md5 hex string
    • decodeHex

      public static byte[] decodeHex(char[] data)
      Converts an array of character bytes representing hexadecimal values into an array of bytes of those same values. The returned array will be half the length of the passed array, as it takes two characters to represent any given byte. An exception is thrown if the passed char array has an odd number of elements.
      Parameters:
      data - array of input data containing hex characters
      Returns:
      byte array containing teh binary data decoded from the given input data