-
public class MD5This class provides utility methods for calculating MD5 hashes. It uses the Java MessageDigest class to perform the hash calculations. All methods are synchronized to ensure thread safety when accessing the shared MessageDigest instance.
-
-
Method Summary
Modifier and Type Method Description static synchronized voidhash(ByteArray result, ByteArray input)Calculates the MD5 hash of the given input byte array and stores the result as a hexadecimal string in the result byte array.This method uses the MessageDigest class with the MD5 algorithm to compute the hash.The result is then converted to a hexadecimal string representation and stored in the provided result array.This method is synchronized to prevent concurrent access to the shared MessageDigest instance. static synchronized Stringhash(String input)Generates the MD5 hash of a given input string.This method takes a string as input and calculates its MD5 hash value.The result is returned as a hexadecimal string. static synchronized Stringhash(Array<byte> input)Calculates the MD5 hash of the given byte array.This method takes a byte array as input and computes its MD5 hash.The hash is returned as a hexadecimal string. static voidtoHex(Array<byte> a, ByteArray b)Converts a byte array to its hexadecimal representation and appends it to a ByteArray.This method iterates through the input byte array, converting each byte into two hexadecimalcharacters. -
-
Method Detail
-
hash
static synchronized void hash(ByteArray result, ByteArray input)
Calculates the MD5 hash of the given input byte array and stores the result as a hexadecimal string in the result byte array.This method uses the MessageDigest class with the MD5 algorithm to compute the hash.The result is then converted to a hexadecimal string representation and stored in the provided result array.This method is synchronized to prevent concurrent access to the shared MessageDigest instance.
- Parameters:
result- The byte array to store the resulting hexadecimal hash.input- The byte array containing the input data to be hashed.
-
hash
static synchronized String hash(String input)
Generates the MD5 hash of a given input string.This method takes a string as input and calculates its MD5 hash value.The result is returned as a hexadecimal string.
- Parameters:
input- The input string to be hashed.
-
hash
static synchronized String hash(Array<byte> input)
Calculates the MD5 hash of the given byte array.This method takes a byte array as input and computes its MD5 hash.The hash is returned as a hexadecimal string.
- Parameters:
input- The byte array to hash.
-
toHex
static void toHex(Array<byte> a, ByteArray b)
Converts a byte array to its hexadecimal representation and appends it to a ByteArray.This method iterates through the input byte array, converting each byte into two hexadecimalcharacters. These characters are then appended to the provided ByteArray.
- Parameters:
a- The byte array to be converted to hexadecimal.b- The ByteArray to which the hexadecimal representation will be appended.The hexadecimal representation is appended starting at the offset `b.offset + b.length`.The length of the ByteArray is updated to reflect the added hexadecimal characters.
-
-
-
-