public class HMacSha extends HMac
This class only instantiates the super
HMac class and specifies
SHA as hash algorithm to be used.
An application wishing to perform a MAC computation, at first has to create a
MAC object by instantiating the
Mac class through a proper
getInstance factory method thereby specifying the MAC algorithm
to be used. Calculating a HMAC based on the Sha hash algorithm, may be
initiated as follows:
Mac sha_HMAC = Mac.getInstance("HMAC/SHA");
After properly initializing the MAC object with one entity's secret key, the
data to be processed is applied by one (or more) calls to the
update methods. The MAC computation is concluded by using
doFinal. If the data can be processed without calling any
doFinal can be called immediately
after initializing the MAC object:
sha_HMAC.init(secret_key); byte mac_data = sha_HMAC.doFinal(data);
After the MAC finally has been calculated, the MAC object automatically is reset for being able to be used for further MAC computations, either by using the same secret key again, or using a new key by properly re-initializing this MAC object.
|Constructor and Description|
engineDoFinal, engineGetMacLength, engineInit, engineReset, engineUpdate, engineUpdate
public HMacSha() throws java.security.NoSuchAlgorithmException
HMacclass thereby specifying SHA as hash function to be used.
java.security.NoSuchAlgorithmException- if there is no implementation for SHA