Package ghidra.util

# Class MD5Utilities

java.lang.Object
ghidra.util.MD5Utilities

public class MD5Utilities extends Object

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `SALT_LENGTH`
  `static final int`
  `SALTED_HASH_LENGTH`
  `static final int`
  `UNSALTED_HASH_LENGTH`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `MD5Utilities()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static char[]`
  `getMD5Hash(char[] msg)`
  Generate MD5 hash in a hex character representation
  `static String`
  `getMD5Hash(File file)`
  Generate MD5 message digest hash for specified file contents.
  `static String`
  `getMD5Hash(InputStream in)`
  Generate MD5 message digest hash for specified input stream.
  `static String`
  `getMD5Hash(List<String> values)`
  Generate combined MD5 message digest hash for all values in the specified values list.
  `static char[]`
  `getSaltedMD5Hash(char[] msg)`
  Generate salted MD5 hash for specified message using random salt.
  `static char[]`
  `getSaltedMD5Hash(char[] salt, char[] msg)`
  Generate salted MD5 hash for specified message.
  `static char[]`
  `hexDump(byte[] data)`
  Convert binary data to a sequence of hex characters.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### SALT_LENGTH

    public static final int SALT_LENGTH
    See Also:
      - Constant Field Values

  - ### UNSALTED_HASH_LENGTH

    public static final int UNSALTED_HASH_LENGTH
    See Also:
      - Constant Field Values

  - ### SALTED_HASH_LENGTH

    public static final int SALTED_HASH_LENGTH
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### MD5Utilities

    public MD5Utilities()

- ## Method Details

  - ### getMD5Hash

    public static char[] getMD5Hash(char[] msg)
    Generate MD5 hash in a hex character representation
    Parameters:
      `msg` - message text
    Returns:
      hex hash value in text format

  - ### getSaltedMD5Hash

    public static char[] getSaltedMD5Hash(char[] salt, char[] msg)
    Generate salted MD5 hash for specified message. Supplied salt is returned as prefix to returned hash.
    Parameters:
      `salt` - digest salt (use empty string for no salt)
      `msg` - message text
    Returns:
      salted hash using specified salt which is returned as a prefix to the hash

  - ### getSaltedMD5Hash

    public static char[] getSaltedMD5Hash(char[] msg)
    Generate salted MD5 hash for specified message using random salt. First 4-characters of returned hash correspond to the salt data.
    Parameters:
      `msg` - message text
    Returns:
      salted hash using randomly generated salt which is returned as a prefix to the hash

  - ### getMD5Hash

    public static String getMD5Hash(InputStream in) throws IOException
    Generate MD5 message digest hash for specified input stream. Stream will be read until EOF is reached.
    Parameters:
      `in` - input stream
    Returns:
      message digest hash
    Throws:
      `IOException` - if reading input stream produces an error

  - ### getMD5Hash

    public static String getMD5Hash(File file) throws IOException
    Generate MD5 message digest hash for specified file contents.
    Parameters:
      `file` - file to be read
    Returns:
      message digest hash
    Throws:
      `IOException` - if opening or reading file produces an error

  - ### getMD5Hash

    public static String getMD5Hash(List<String> values)
    Generate combined MD5 message digest hash for all values in the specified values list.
    Parameters:
      `values` - list of text strings
    Returns:
      MD5 message digest hash

  - ### hexDump

    public static char[] hexDump(byte[] data)
    Convert binary data to a sequence of hex characters.
    Parameters:
      `data` - binary data
    Returns:
      hex character representation of data