Package ghidra.util
Class HashUtilities
- java.lang.Object
- 
- ghidra.util.HashUtilities
 
- 
 public class HashUtilities extends java.lang.Object
- 
- 
Field SummaryFields Modifier and Type Field Description static java.lang.StringMD5_ALGORITHMstatic intMD5_SALTED_HASH_LENGTHstatic intMD5_UNSALTED_HASH_LENGTHstatic intSALT_LENGTHstatic java.lang.StringSHA256_ALGORITHMstatic intSHA256_SALTED_HASH_LENGTHstatic intSHA256_UNSALTED_HASH_LENGTH
 - 
Constructor SummaryConstructors Constructor Description HashUtilities()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static char[]getHash(java.lang.String algorithm, char[] msg)Generate hash in a hex character representationstatic java.lang.StringgetHash(java.lang.String algorithm, java.io.File file)Generate message digest hash for specified file contents.static java.lang.StringgetHash(java.lang.String algorithm, java.io.InputStream in)Generate message digest hash for specified input stream.static java.lang.StringgetHash(java.lang.String algorithm, java.util.List<java.lang.String> values)Generate combined message digest hash for all values in the specified values list.static char[]getSaltedHash(java.lang.String algorithm, char[] msg)Generate salted hash for specified message using random salt.static char[]getSaltedHash(java.lang.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 Detail- 
MD5_ALGORITHMpublic static java.lang.String MD5_ALGORITHM 
 - 
SHA256_ALGORITHMpublic static java.lang.String SHA256_ALGORITHM 
 - 
SALT_LENGTHpublic static final int SALT_LENGTH - See Also:
- Constant Field Values
 
 - 
MD5_UNSALTED_HASH_LENGTHpublic static final int MD5_UNSALTED_HASH_LENGTH - See Also:
- Constant Field Values
 
 - 
MD5_SALTED_HASH_LENGTHpublic static final int MD5_SALTED_HASH_LENGTH - See Also:
- Constant Field Values
 
 - 
SHA256_UNSALTED_HASH_LENGTHpublic static final int SHA256_UNSALTED_HASH_LENGTH - See Also:
- Constant Field Values
 
 - 
SHA256_SALTED_HASH_LENGTHpublic static final int SHA256_SALTED_HASH_LENGTH - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
getHashpublic static char[] getHash(java.lang.String algorithm, char[] msg)Generate hash in a hex character representation- Parameters:
- algorithm- message digest algorithm
- msg- message text
- Returns:
- hex hash value in text format
- Throws:
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported algorithms
 
 - 
getSaltedHashpublic static char[] getSaltedHash(java.lang.String algorithm, char[] salt, char[] msg)Generate salted hash for specified message. Supplied salt is returned as prefix to returned hash.- Parameters:
- algorithm- message digest algorithm
- 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
- Throws:
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported hash algorithms
 
 - 
getSaltedHashpublic static char[] getSaltedHash(java.lang.String algorithm, char[] msg)Generate salted hash for specified message using random salt. First 4-characters of returned hash correspond to the salt data.- Parameters:
- algorithm- message digest algorithm
- msg- message text
- Returns:
- salted hash using randomly generated salt which is returned as a prefix to the hash
- Throws:
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported hash algorithms
 
 - 
getHashpublic static java.lang.String getHash(java.lang.String algorithm, java.io.InputStream in) throws java.io.IOExceptionGenerate message digest hash for specified input stream. Stream will be read until EOF is reached.- Parameters:
- algorithm- message digest algorithm
- in- input stream
- Returns:
- message digest hash
- Throws:
- java.io.IOException- if reading input stream produces an error
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported hash algorithms
 
 - 
getHashpublic static java.lang.String getHash(java.lang.String algorithm, java.io.File file) throws java.io.IOExceptionGenerate message digest hash for specified file contents.- Parameters:
- algorithm- message digest algorithm
- file- file to be read
- Returns:
- message digest hash
- Throws:
- java.io.IOException- if opening or reading file produces an error
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported hash algorithms
 
 - 
getHashpublic static java.lang.String getHash(java.lang.String algorithm, java.util.List<java.lang.String> values)Generate combined message digest hash for all values in the specified values list.- Parameters:
- algorithm- message digest algorithm
- values- list of text strings
- Returns:
- message digest hash
- Throws:
- java.lang.IllegalArgumentException- if specified algorithm is not supported
- See Also:
- for supported hash algorithms
 
 - 
hexDumppublic static char[] hexDump(byte[] data) Convert binary data to a sequence of hex characters.- Parameters:
- data- binary data
- Returns:
- hex character representation of data
 
 
- 
 
-