Module java.base
Package javax.crypto

Class Mac

java.lang.Object
javax.crypto.Mac
All Implemented Interfaces:
Cloneable

public class Mac extends Object implements Cloneable
This class provides the functionality of a "Message Authentication Code" (MAC) algorithm.

A MAC provides a way to check the integrity of information transmitted over or stored in an unreliable medium, based on a secret key. Typically, message authentication codes are used between two parties that share a secret key in order to validate information transmitted between these parties.

A MAC mechanism that is based on cryptographic hash functions is referred to as HMAC. HMAC can be used with any cryptographic hash function, e.g., SHA256 or SHA384, in combination with a secret shared key. HMAC is specified in RFC 2104.

Every implementation of the Java platform is required to support the following standard Mac algorithms:

  • HmacSHA1
  • HmacSHA256
These algorithms are described in the Mac section of the Java Security Standard Algorithm Names Specification. Consult the release documentation for your implementation to see if any other algorithms are supported.

Since:
1.4