java.lang.Object
org.seppiko.commons.utils.codec.HashCryptUtil
Hash Crypt Util
- Author:
- Leonard Woo
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]hmacCrypt(HmacAlgorithms algorithm, byte[] data, byte[] key) Simplifies commonMactasks.static byte[]mdCrypt(MessageDigestAlgorithms algorithm, byte[] data) Simplifies commonMessageDigesttasks.static byte[]pbkdf2Crypt(HmacAlgorithms algorithm, char[] password, byte[] salt, int iterations, int keySize) Simplifies common PBKDF2 tasks
-
Constructor Details
-
HashCryptUtil
public HashCryptUtil()
-
-
Method Details
-
mdCrypt
public static byte[] mdCrypt(MessageDigestAlgorithms algorithm, byte[] data) throws IllegalArgumentException Simplifies commonMessageDigesttasks.- Parameters:
algorithm- Message Digest Algorithmdata- data to hash- Returns:
- complete hash value
- Throws:
IllegalArgumentException- when aNoSuchAlgorithmExceptionis caught.
-
hmacCrypt
public static byte[] hmacCrypt(HmacAlgorithms algorithm, byte[] data, byte[] key) throws InvalidKeyException, IllegalArgumentException Simplifies commonMactasks.- Parameters:
algorithm- Hmac Algorithmdata- 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.
-
pbkdf2Crypt
public static byte[] pbkdf2Crypt(HmacAlgorithms algorithm, char[] password, byte[] salt, int iterations, int keySize) Simplifies common PBKDF2 tasks- Parameters:
algorithm- PBKDF2With<Hmac Algorithm>password- 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.
-