Package io.mosip.kernel.core.util
Class HMACUtils
- java.lang.Object
-
- io.mosip.kernel.core.util.HMACUtils
-
public final class HMACUtils extends Object
This class defines the 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.0.0
- Author:
- Omsaieswar Mulaklauri, Urvil Joshi
-
-
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)static voidupdate(byte[] bytes)Updates the digest using the specified bytestatic byte[]updatedHash()Return the whole update digest
-
-
-
Method Detail
-
generateHash
public static byte[] generateHash(byte[] bytes)
Performs a digest using the specified array of bytes.- Parameters:
bytes- bytes to be hash generation- Returns:
- byte[] generated hash bytes
-
update
public static void update(byte[] bytes)
Updates the digest using the specified byte- Parameters:
bytes- updates the digest using the specified byte
-
updatedHash
public static byte[] updatedHash()
Return the whole update digest- Returns:
- byte[] updated hash bytes
-
digestAsPlainTextWithSalt
public static String digestAsPlainTextWithSalt(byte[] password, byte[] salt)
Return the digest as a plain text with Salt- Parameters:
bytes- digest bytessalt- digest bytes- Returns:
- String converted digest as plain text
-
digestAsPlainText
public static String digestAsPlainText(byte[] bytes)
Return the digest as a plain text- Parameters:
bytes- digest bytes- Returns:
- String converted digest as plain text
-
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
-
-