Package io.mosip.kernel.core.util
Class HMACUtils2
- java.lang.Object
-
- io.mosip.kernel.core.util.HMACUtils2
-
public final class HMACUtils2 extends Object
This class defines the alternate safer HMAC Util to be used in MOSIP Project. The HMAC Util is implemented using desired methods of MessageDigest class of java security package- Since:
- 1.1.4
- Author:
- Sasikumar Ganesan
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decodeBase64(String data)Decodes from BASE64static StringdigestAsPlainText(byte[] bytes)Return the digest as a plain textstatic StringdigestAsPlainTextWithSalt(byte[] password, byte[] salt)Return the digest as a plain text with Saltstatic StringencodeBase64String(byte[] data)Encodes to BASE64 Stringstatic byte[]generateHash(byte[] bytes)Performs a digest using the specified array of bytes.static byte[]generateSalt()Generate Random Salt (with default 16 bytes of length).static byte[]generateSalt(int bytes)Generate Random Salt (with given length)
-
-
-
Method Detail
-
generateHash
public static byte[] generateHash(byte[] bytes) throws NoSuchAlgorithmExceptionPerforms a digest using the specified array of bytes.- Parameters:
bytes- bytes to be hash generation- Returns:
- byte[] generated hash bytes
- Throws:
NoSuchAlgorithmException
-
digestAsPlainTextWithSalt
public static String digestAsPlainTextWithSalt(byte[] password, byte[] salt) throws NoSuchAlgorithmException
Return the digest as a plain text with Salt- Parameters:
bytes- digest bytessalt- digest bytes- Returns:
- String converted digest as plain text
- Throws:
NoSuchAlgorithmException
-
digestAsPlainText
public static String digestAsPlainText(byte[] bytes) throws NoSuchAlgorithmException
Return the digest as a plain text- Parameters:
bytes- digest bytes- Returns:
- String converted digest as plain text
- Throws:
NoSuchAlgorithmException
-
generateSalt
public static byte[] generateSalt()
Generate Random Salt (with default 16 bytes of length).- Returns:
- Random Salt
-
generateSalt
public static byte[] generateSalt(int bytes)
Generate Random Salt (with given length)- Parameters:
bytes- length of random salt- Returns:
- Random Salt of given length
-
encodeBase64String
public static String encodeBase64String(byte[] data)
Encodes to BASE64 String- Parameters:
data- data to encode- Returns:
- encoded data
-
decodeBase64
public static byte[] decodeBase64(String data)
Decodes from BASE64- Parameters:
data- data to decode- Returns:
- decoded data
-
-