java.lang.Object
org.seppiko.commons.utils.crypto.HashUtil
Hash Util
- Author:
- Leonard Woo
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]hmacHash(HmacAlgorithms algorithm, Provider provider, byte[] data, byte[] key) Simplifies commonMactasks.static StringhmacHashString(HmacAlgorithms algorithm, Provider provider, byte[] data, byte[] key) Simplifies commonMactasks.static byte[]mdHash(MessageDigestAlgorithms algorithm, Provider provider, byte[] data) Simplifies commonMessageDigesttasks.static StringmdHashString(MessageDigestAlgorithms algorithm, Provider provider, byte[] data) Simplifies commonMessageDigesttasks.static byte[]pbkdf2Hash(HmacAlgorithms algorithm, Provider provider, char[] password, byte[] salt, int iterations, int keySize) Simplifies common PBKDF2 tasksstatic Stringpbkdf2HashString(HmacAlgorithms algorithm, Provider provider, char[] password, byte[] salt, int iterations, int keySize) Simplifies common PBKDF2 tasks
-
Method Details
-
mdHash
public static byte[] mdHash(MessageDigestAlgorithms algorithm, Provider provider, byte[] data) throws IllegalArgumentException Simplifies commonMessageDigesttasks.- Parameters:
algorithm- Message Digest Algorithmprovider- Hash provider, null is use default providerdata- data to hash- Returns:
- complete hash value
- Throws:
IllegalArgumentException- when aNoSuchAlgorithmExceptionis caught.
-
mdHashString
public static String mdHashString(MessageDigestAlgorithms algorithm, Provider provider, byte[] data) throws IllegalArgumentException Simplifies commonMessageDigesttasks.- Parameters:
algorithm- Message Digest Algorithmprovider- Hash provider, null is use default providerdata- data to hash- Returns:
- complete hash string
- Throws:
IllegalArgumentException- when aNoSuchAlgorithmExceptionis caught.
-
hmacHash
public static byte[] hmacHash(HmacAlgorithms algorithm, Provider provider, byte[] data, byte[] key) throws InvalidKeyException, IllegalArgumentException Simplifies commonMactasks.- Parameters:
algorithm- Hmac Algorithmprovider- Hash provider, null is use default providerdata- data to hash with keykey- the keyed digest- Returns:
- complete hash value including key
- Throws:
InvalidKeyException- if the given key isnullor does not match the allowed pattern.IllegalArgumentException- when aNoSuchAlgorithmExceptionis caught.
-
hmacHashString
public static String hmacHashString(HmacAlgorithms algorithm, Provider provider, byte[] data, byte[] key) throws InvalidKeyException, IllegalArgumentException Simplifies commonMactasks.- Parameters:
algorithm- Hmac Algorithmprovider- Hash provider, null is use default providerdata- data to hash with keykey- the keyed digest- Returns:
- complete hash string including key
- Throws:
InvalidKeyException- if the given key isnullor does not match the allowed pattern.IllegalArgumentException- when aNoSuchAlgorithmExceptionis caught.
-
pbkdf2Hash
public static byte[] pbkdf2Hash(HmacAlgorithms algorithm, Provider provider, char[] password, byte[] salt, int iterations, int keySize) throws IllegalArgumentException Simplifies common PBKDF2 tasks- Parameters:
algorithm- PBKDF2With<Hmac Algorithm>provider- Hash provider, null is use default providerpassword- raw passwordsalt- password saltiterations- iterationkeySize- key size- Returns:
- PBKDF2With<Hmac Algorithm> password
- Throws:
IllegalArgumentException- password or salt is null, number is wrong or could not execute task.
-
pbkdf2HashString
public static String pbkdf2HashString(HmacAlgorithms algorithm, Provider provider, char[] password, byte[] salt, int iterations, int keySize) throws IllegalArgumentException Simplifies common PBKDF2 tasks- Parameters:
algorithm- PBKDF2With<Hmac Algorithm>provider- Hash provider, null is use default providerpassword- raw passwordsalt- password saltiterations- iterationkeySize- key size- Returns:
- PBKDF2With<Hmac Algorithm> password string
- Throws:
IllegalArgumentException- password or salt is null, number is wrong or could not execute task.
-