public class HashUtils extends Object
| Modifier and Type | Method and Description | 
|---|---|
static byte[] | 
hash(HashAlgorithm algorithm,
    byte[] bytes)
Generates a hash value, in the form of an array of bytes, by digesting a provided bytes based on
 the provided hash algorithm. 
 | 
static byte[] | 
hash(HashAlgorithm algorithm,
    File file)
Generates a hash value, in the form of an array of bytes, by digesting a provided input stream
 based on the provided hash algorithm. 
 | 
static byte[] | 
hash(HashAlgorithm algorithm,
    InputStream is)
Generates a hash value, in the form of an array of bytes, by digesting a provided input stream
 based on the provided hash algorithm. 
 | 
static byte[] | 
processDigest(HashAlgorithm algorithm,
             byte[] mdbytes)
Processes the provided hash value, truncating the value based on the width of the provided hash
 algorithm. 
 | 
static byte[] | 
toArray(List<Byte> bytes)
Converts a list of bytes into an array of bytes. 
 | 
static byte[] | 
toBytes(String hashHexBytes)  | 
static String | 
toHexString(byte[] bytes)
Converts an array of bytes into a hexadecimal string. 
 | 
static String | 
toHexString(List<Byte> bytes)
Converts an list of bytes into a hexadecimal string. 
 | 
static List<Byte> | 
toList(byte[] bytes)
Converts an array of bytes into a list of bytes. 
 | 
public static List<Byte> toList(byte[] bytes)
bytes - the array of bytes to convertpublic static byte[] toArray(List<Byte> bytes)
bytes - a list of bytespublic static String toHexString(byte[] bytes)
bytes - the array of bytes to convertpublic static String toHexString(List<Byte> bytes)
bytes - the list of bytes to convertpublic static byte[] toBytes(String hashHexBytes)
public static byte[] hash(HashAlgorithm algorithm, File file) throws NoSuchAlgorithmException, IOException
algorithm - the hash function to usefile - the file to read bytes fromNoSuchAlgorithmException - if the selected hash function is not supportedIOException - if an error occured while reading the input streampublic static byte[] hash(HashAlgorithm algorithm, InputStream is) throws NoSuchAlgorithmException, IOException
algorithm - the hash function to useis - the input stream to read bytes fromNoSuchAlgorithmException - if the selected hash function is not supportedIOException - if an error occured while reading the input streampublic static byte[] hash(HashAlgorithm algorithm, byte[] bytes) throws NoSuchAlgorithmException
algorithm - the hash function to usebytes - the bytes to digestNoSuchAlgorithmException - if the selected hash function is not supportedpublic static byte[] processDigest(HashAlgorithm algorithm, byte[] mdbytes)
algorithm - the hash function to usemdbytes - the digest bytes to truncateCopyright © 2020 National Institute of Standards and Technology. All rights reserved.