Package ghidra.util
Class HashUtilities
java.lang.Object
ghidra.util.HashUtilities
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Generate combined message digest hash for the bytes in the specified array.static char[]
Generate hash in a hex character representationstatic String
Generate message digest hash for specified file contents.static String
getHash
(String algorithm, InputStream in) Generate message digest hash for specified input stream.static String
Generate combined message digest hash for all values in the specified values list.static char[]
getSaltedHash
(String algorithm, char[] msg) Generate salted hash for specified message using random salt.static char[]
getSaltedHash
(String algorithm, char[] salt, char[] msg) Generate salted hash for specified message.static char[]
hexDump
(byte[] data) Convert binary data to a sequence of hex characters.
-
Field Details
-
MD5_ALGORITHM
-
SHA256_ALGORITHM
-
SALT_LENGTH
public static final int SALT_LENGTH- See Also:
-
MD5_UNSALTED_HASH_LENGTH
public static final int MD5_UNSALTED_HASH_LENGTH- See Also:
-
MD5_SALTED_HASH_LENGTH
public static final int MD5_SALTED_HASH_LENGTH- See Also:
-
SHA256_UNSALTED_HASH_LENGTH
public static final int SHA256_UNSALTED_HASH_LENGTH- See Also:
-
SHA256_SALTED_HASH_LENGTH
public static final int SHA256_SALTED_HASH_LENGTH- See Also:
-
-
Constructor Details
-
HashUtilities
public HashUtilities()
-
-
Method Details
-
getHash
Generate hash in a hex character representation- Parameters:
algorithm
- message digest algorithmmsg
- message text- Returns:
- hex hash value in text format
- Throws:
IllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getSaltedHash
Generate salted hash for specified message. Supplied salt is returned as prefix to returned hash.- Parameters:
algorithm
- message digest algorithmsalt
- 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
- Throws:
IllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getSaltedHash
Generate salted hash for specified message using random salt. First 4-characters of returned hash correspond to the salt data.- Parameters:
algorithm
- message digest algorithmmsg
- message text- Returns:
- salted hash using randomly generated salt which is returned as a prefix to the hash
- Throws:
IllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getHash
Generate message digest hash for specified input stream. Stream will be read until EOF is reached.- Parameters:
algorithm
- message digest algorithmin
- input stream- Returns:
- message digest hash
- Throws:
IOException
- if reading input stream produces an errorIllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getHash
Generate message digest hash for specified file contents.- Parameters:
algorithm
- message digest algorithmfile
- file to be read- Returns:
- message digest hash
- Throws:
IOException
- if opening or reading file produces an errorIllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getHash
Generate combined message digest hash for all values in the specified values list.- Parameters:
algorithm
- message digest algorithmvalues
- list of text strings- Returns:
- message digest hash
- Throws:
IllegalArgumentException
- if specified algorithm is not supported- See Also:
-
getHash
Generate combined message digest hash for the bytes in the specified array.- Parameters:
algorithm
- message digest algorithmvalues
- array of bytes to hash- Returns:
- message digest hash
- Throws:
IllegalArgumentException
- if specified algorithm is not supported- See Also:
-
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
-