Package com.helixframework.crypto.mac
Class MacCrypto
java.lang.Object
com.helixframework.crypto.mac.MacCrypto
Verifies a MAC.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]compute(byte[] data) Computes the message authentication code (MAC) for the given data.byte[]Computes the message authentication code (MAC) for the given data.byte[]Computes the message authentication code (MAC) for the given data using the specified charset.computeAsBase64(byte[] data) Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.computeAsBase64(String data) Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.computeAsBase64(String data, Charset charset) Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.voidverify(byte[] mac, byte[] data) Verifies whether mac is a correct authentication code (MAC) for data.
-
Method Details
-
compute
Computes the message authentication code (MAC) for the given data.- Parameters:
data- the data to compute the MAC for- Returns:
- the computed MAC as a byte array
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
compute
Computes the message authentication code (MAC) for the given data.- Parameters:
data- the data to compute the MAC for- Returns:
- the computed MAC as a byte array
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
compute
Computes the message authentication code (MAC) for the given data using the specified charset.- Parameters:
data- the data to compute the MAC forcharset- the charset used to encode the data as bytes- Returns:
- the computed MAC as a byte array
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
computeAsBase64
Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.- Parameters:
data- the data to compute the MAC for- Returns:
- the computed MAC as a Base64 encoded string
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
computeAsBase64
Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.- Parameters:
data- the data to compute the MAC for- Returns:
- the computed MAC as a Base64 encoded string
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
computeAsBase64
Computes the message authentication code (MAC) for the given data and returns it as a Base64 encoded string.- Parameters:
data- the data to compute the MAC forcharset- the charset used to encode the data as bytes- Returns:
- the computed MAC as a Base64 encoded string
- Throws:
GeneralSecurityException- if an error occurs during MAC computation
-
verify
Verifies whether mac is a correct authentication code (MAC) for data.- Parameters:
mac- message authentication codedata- data- Throws:
GeneralSecurityException- if the message does not validate
-