# Mac

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Protected Ctors](https://developer.android.com/reference/javax/crypto/Mac#proctors)\|[Methods](https://developer.android.com/reference/javax/crypto/Mac#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/javax/crypto/Mac#inhmethods)  

# Mac

`
public


class
Mac
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


implements

`[Cloneable](https://developer.android.com/reference/java/lang/Cloneable)`


`

|---|------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | javax.crypto.Mac |

<br />

*** ** * ** ***

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., MD5 or SHA-1, in combination with a secret shared key. HMAC is specified in RFC 2104.

Android provides the following`Mac`algorithms:

|     Algorithm     | Supported API Levels |
|-------------------|----------------------|
| AESCMAC           | 31+                  |
| DESMAC            | 1-8                  |
| DESMAC/CFB8       | 1-8                  |
| DESedeMAC         | 1-8                  |
| DESedeMAC/CFB8    | 1-8                  |
| DESedeMAC64       | 1-8                  |
| DESwithISO9797    | 1-8                  |
| HmacMD5           | 1+                   |
| HmacSHA1          | 1+                   |
| HmacSHA224        | 1-8,22+              |
| HmacSHA256        | 1+                   |
| HmacSHA384        | 1+                   |
| HmacSHA512        | 1+                   |
| ISO9797ALG3MAC    | 1-8                  |
| PBEwithHmacSHA    | 1+                   |
| PBEwithHmacSHA1   | 1+                   |
| PBEwithHmacSHA224 | 26-31                |
| PBEwithHmacSHA256 | 26-31                |
| PBEwithHmacSHA384 | 26-31                |
| PBEwithHmacSHA512 | 26-31                |

These algorithms are described in the[Mac section](https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Mac)of the Java Cryptography Architecture Standard Algorithm Name Documentation.

<br />

## Summary

|                                                                                                                                                                                                  ### Protected constructors                                                                                                                                                                                                  ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Mac](https://developer.android.com/reference/javax/crypto/Mac#Mac(javax.crypto.MacSpi,%20java.security.Provider,%20java.lang.String))`(`[MacSpi](https://developer.android.com/reference/javax/crypto/MacSpi)` macSpi, `[Provider](https://developer.android.com/reference/java/security/Provider)` provider, `[String](https://developer.android.com/reference/java/lang/String)` algorithm) ` Creates a MAC object. |

|                                                                                                                                                                                                                                           ### Public methods                                                                                                                                                                                                                                            ||
|-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final `[Object](https://developer.android.com/reference/java/lang/Object)         | ` `[clone](https://developer.android.com/reference/javax/crypto/Mac#clone())`() ` Returns a clone if the provider implementation is cloneable.                                                                                                                                                                                                                                                                     |
| ` final byte[]`                                                                     | ` `[doFinal](https://developer.android.com/reference/javax/crypto/Mac#doFinal(byte[]))`(byte[] input) ` Processes the given array of bytes and finishes the MAC operation.                                                                                                                                                                                                                                         |
| ` final void`                                                                       | ` `[doFinal](https://developer.android.com/reference/javax/crypto/Mac#doFinal(byte[],%20int))`(byte[] output, int outOffset) ` Finishes the MAC operation.                                                                                                                                                                                                                                                         |
| ` final byte[]`                                                                     | ` `[doFinal](https://developer.android.com/reference/javax/crypto/Mac#doFinal())`() ` Finishes the MAC operation.                                                                                                                                                                                                                                                                                                  |
| ` final `[String](https://developer.android.com/reference/java/lang/String)         | ` `[getAlgorithm](https://developer.android.com/reference/javax/crypto/Mac#getAlgorithm())`() ` Returns the algorithm name of this`Mac`object.                                                                                                                                                                                                                                                                     |
| ` static final `[Mac](https://developer.android.com/reference/javax/crypto/Mac)     | ` `[getInstance](https://developer.android.com/reference/javax/crypto/Mac#getInstance(java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` algorithm) ` Returns a`Mac`object that implements the specified MAC algorithm.                                                                                                                                                      |
| ` static final `[Mac](https://developer.android.com/reference/javax/crypto/Mac)     | ` `[getInstance](https://developer.android.com/reference/javax/crypto/Mac#getInstance(java.lang.String,%20java.lang.String))`(`[String](https://developer.android.com/reference/java/lang/String)` algorithm, `[String](https://developer.android.com/reference/java/lang/String)` provider) ` Returns a`Mac`object that implements the specified MAC algorithm.                                                   |
| ` static final `[Mac](https://developer.android.com/reference/javax/crypto/Mac)     | ` `[getInstance](https://developer.android.com/reference/javax/crypto/Mac#getInstance(java.lang.String,%20java.security.Provider))`(`[String](https://developer.android.com/reference/java/lang/String)` algorithm, `[Provider](https://developer.android.com/reference/java/security/Provider)` provider) ` Returns a`Mac`object that implements the specified MAC algorithm.                                     |
| ` final int`                                                                        | ` `[getMacLength](https://developer.android.com/reference/javax/crypto/Mac#getMacLength())`() ` Returns the length of the MAC in bytes.                                                                                                                                                                                                                                                                            |
| ` final `[Provider](https://developer.android.com/reference/java/security/Provider) | ` `[getProvider](https://developer.android.com/reference/javax/crypto/Mac#getProvider())`() ` Returns the provider of this`Mac`object.                                                                                                                                                                                                                                                                             |
| ` final void`                                                                       | ` `[init](https://developer.android.com/reference/javax/crypto/Mac#init(java.security.Key,%20java.security.spec.AlgorithmParameterSpec))`(`[Key](https://developer.android.com/reference/java/security/Key)` key, `[AlgorithmParameterSpec](https://developer.android.com/reference/java/security/spec/AlgorithmParameterSpec)` params) ` Initializes this`Mac`object with the given key and algorithm parameters. |
| ` final void`                                                                       | ` `[init](https://developer.android.com/reference/javax/crypto/Mac#init(java.security.Key))`(`[Key](https://developer.android.com/reference/java/security/Key)` key) ` Initializes this`Mac`object with the given key.                                                                                                                                                                                             |
| ` final void`                                                                       | ` `[reset](https://developer.android.com/reference/javax/crypto/Mac#reset())`() ` Resets this`Mac`object.                                                                                                                                                                                                                                                                                                          |
| ` final void`                                                                       | ` `[update](https://developer.android.com/reference/javax/crypto/Mac#update(byte[]))`(byte[] input) ` Processes the given array of bytes.                                                                                                                                                                                                                                                                          |
| ` final void`                                                                       | ` `[update](https://developer.android.com/reference/javax/crypto/Mac#update(byte[],%20int,%20int))`(byte[] input, int offset, int len) ` Processes the first`len`bytes in`input`, starting at`offset`inclusive.                                                                                                                                                                                                    |
| ` final void`                                                                       | ` `[update](https://developer.android.com/reference/javax/crypto/Mac#update(java.nio.ByteBuffer))`(`[ByteBuffer](https://developer.android.com/reference/java/nio/ByteBuffer)` input) ` Processes`input.remaining()`bytes in the ByteBuffer`input`, starting at`input.position()`.                                                                                                                                 |
| ` final void`                                                                       | ` `[update](https://developer.android.com/reference/javax/crypto/Mac#update(byte))`(byte input) ` Processes the given byte.                                                                                                                                                                                                                                                                                        |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Protected constructors

### Mac

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
protected Mac (MacSpi macSpi, 
                Provider provider, 
                String algorithm)
```

Creates a MAC object.

<br />

|                  Parameters                  ||
|-------------|---------------------------------|
| `macSpi`    | `MacSpi`: the delegate <br />   |
| `provider`  | `Provider`: the provider <br /> |
| `algorithm` | `String`: the algorithm <br />  |

## Public methods

### clone

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final Object clone ()
```

Returns a clone if the provider implementation is cloneable.

<br />

|                                                             Returns                                                             ||
|--------------------------------------------------------------------|-------------------------------------------------------------|
| [Object](https://developer.android.com/reference/java/lang/Object) | a clone if the provider implementation is cloneable. <br /> |

|                                                                                    Throws                                                                                     ||
|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [CloneNotSupportedException](https://developer.android.com/reference/java/lang/CloneNotSupportedException) | if this is called on a delegate that does not support`Cloneable`. |

### doFinal

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final byte[] doFinal (byte[] input)
```

Processes the given array of bytes and finishes the MAC operation.

A call to this method resets this`Mac`object to the state it was in when previously initialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`. That is, the object is reset and available to generate another MAC from the same key, if desired, via new calls to`update`and`doFinal`. (In order to reuse this`Mac`object with a different key, it must be reinitialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`.

<br />

|              Parameters               ||
|---------|------------------------------|
| `input` | `byte`: data in bytes <br /> |

|             Returns              ||
|----------|------------------------|
| `byte[]` | the MAC result. <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |

### doFinal

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void doFinal (byte[] output, 
                int outOffset)
```

Finishes the MAC operation.

A call to this method resets this`Mac`object to the state it was in when previously initialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`. That is, the object is reset and available to generate another MAC from the same key, if desired, via new calls to`update`and`doFinal`. (In order to reuse this`Mac`object with a different key, it must be reinitialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`.

The MAC result is stored in`output`, starting at`outOffset`inclusive.

<br />

|                               Parameters                                ||
|-------------|------------------------------------------------------------|
| `output`    | `byte`: the buffer where the MAC result is stored <br />   |
| `outOffset` | `int`: the offset in`output`where the MAC is stored <br /> |

|                                                                            Throws                                                                             ||
|---------------------------------------------------------------------------------------------------|------------------------------------------------------------|
| [ShortBufferException](https://developer.android.com/reference/javax/crypto/ShortBufferException) | if the given output buffer is too small to hold the result |
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException)  | if this`Mac`has not been initialized.                      |

### doFinal

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final byte[] doFinal ()
```

Finishes the MAC operation.

A call to this method resets this`Mac`object to the state it was in when previously initialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`. That is, the object is reset and available to generate another MAC from the same key, if desired, via new calls to`update`and`doFinal`. (In order to reuse this`Mac`object with a different key, it must be reinitialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`.

<br />

|             Returns              ||
|----------|------------------------|
| `byte[]` | the MAC result. <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |

### getAlgorithm

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final String getAlgorithm ()
```

Returns the algorithm name of this`Mac`object.

This is the same name that was specified in one of the`getInstance`calls that created this`Mac`object.

<br />

|                                                      Returns                                                      ||
|--------------------------------------------------------------------|-----------------------------------------------|
| [String](https://developer.android.com/reference/java/lang/String) | the algorithm name of this`Mac`object. <br /> |

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Mac getInstance (String algorithm)
```

Returns a`Mac`object that implements the specified MAC algorithm.

This method traverses the list of registered security Providers, starting with the most preferred Provider. A new Mac object encapsulating the MacSpi implementation from the first Provider that supports the specified algorithm is returned.

Note that the list of registered providers may be retrieved via the[Security.getProviders()](https://developer.android.com/reference/java/security/Security#getProviders())method.

<br />

|                                                                                                                                                       Parameters                                                                                                                                                        ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `algorithm` | `String`: the standard name of the requested MAC algorithm. See the Mac section in the[Java Cryptography Architecture Standard Algorithm Name Documentation](https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Mac)for information about standard algorithm names. <br /> |

|                                           Returns                                           ||
|-----------------------------------------------------------------|----------------------------|
| [Mac](https://developer.android.com/reference/javax/crypto/Mac) | the new`Mac`object. <br /> |

|                                                                                          Throws                                                                                          ||
|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------|
| [NoSuchAlgorithmException](https://developer.android.com/reference/java/security/NoSuchAlgorithmException) | if no Provider supports a MacSpi implementation for the specified algorithm. |

**See also:**

- [Provider](https://developer.android.com/reference/java/security/Provider)  

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Mac getInstance (String algorithm, 
                String provider)
```

Returns a`Mac`object that implements the specified MAC algorithm.

A new Mac object encapsulating the MacSpi implementation from the specified provider is returned. The specified provider must be registered in the security provider list.

Note that the list of registered providers may be retrieved via the[Security.getProviders()](https://developer.android.com/reference/java/security/Security#getProviders())method.

<br />

|                                                                                                                                                       Parameters                                                                                                                                                        ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `algorithm` | `String`: the standard name of the requested MAC algorithm. See the Mac section in the[Java Cryptography Architecture Standard Algorithm Name Documentation](https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Mac)for information about standard algorithm names. <br /> |
| `provider`  | `String`: the name of the provider. <br />                                                                                                                                                                                                                                                                 |

|                                           Returns                                           ||
|-----------------------------------------------------------------|----------------------------|
| [Mac](https://developer.android.com/reference/javax/crypto/Mac) | the new`Mac`object. <br /> |

|                                                                                                      Throws                                                                                                      ||
|------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------|
| [NoSuchAlgorithmException](https://developer.android.com/reference/java/security/NoSuchAlgorithmException) | if a MacSpi implementation for the specified algorithm is not available from the specified provider. |
| [NoSuchProviderException](https://developer.android.com/reference/java/security/NoSuchProviderException)   | if the specified provider is not registered in the security provider list.                           |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)     | if the`provider`is null or empty.                                                                    |

**See also:**

- [Provider](https://developer.android.com/reference/java/security/Provider)  

### getInstance

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public static final Mac getInstance (String algorithm, 
                Provider provider)
```

Returns a`Mac`object that implements the specified MAC algorithm.

A new Mac object encapsulating the MacSpi implementation from the specified Provider object is returned. Note that the specified Provider object does not have to be registered in the provider list.

<br />

|                                                                                                                                                       Parameters                                                                                                                                                        ||
|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `algorithm` | `String`: the standard name of the requested MAC algorithm. See the Mac section in the[Java Cryptography Architecture Standard Algorithm Name Documentation](https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#Mac)for information about standard algorithm names. <br /> |
| `provider`  | `Provider`: the provider. <br />                                                                                                                                                                                                                                                                           |

|                                           Returns                                           ||
|-----------------------------------------------------------------|----------------------------|
| [Mac](https://developer.android.com/reference/javax/crypto/Mac) | the new`Mac`object. <br /> |

|                                                                                                         Throws                                                                                                          ||
|------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------|
| [NoSuchAlgorithmException](https://developer.android.com/reference/java/security/NoSuchAlgorithmException) | if a MacSpi implementation for the specified algorithm is not available from the specified Provider object. |
| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException)     | if the`provider`is null.                                                                                    |

**See also:**

- [Provider](https://developer.android.com/reference/java/security/Provider)  

### getMacLength

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final int getMacLength ()
```

Returns the length of the MAC in bytes.

<br />

|                Returns                 ||
|-------|---------------------------------|
| `int` | the MAC length in bytes. <br /> |

### getProvider

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final Provider getProvider ()
```

Returns the provider of this`Mac`object.

<br />

|                                                       Returns                                                       ||
|----------------------------------------------------------------------------|-----------------------------------------|
| [Provider](https://developer.android.com/reference/java/security/Provider) | the provider of this`Mac`object. <br /> |

### init

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void init (Key key, 
                AlgorithmParameterSpec params)
```

Initializes this`Mac`object with the given key and algorithm parameters.

<br />

|                              Parameters                              ||
|----------|------------------------------------------------------------|
| `key`    | `Key`: the key. <br />                                     |
| `params` | `AlgorithmParameterSpec`: the algorithm parameters. <br /> |

|                                                                                              Throws                                                                                               ||
|--------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| [InvalidKeyException](https://developer.android.com/reference/java/security/InvalidKeyException)                               | if the given key is inappropriate for initializing this MAC.      |
| [InvalidAlgorithmParameterException](https://developer.android.com/reference/java/security/InvalidAlgorithmParameterException) | if the given algorithm parameters are inappropriate for this MAC. |

### init

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void init (Key key)
```

Initializes this`Mac`object with the given key.

<br />

|          Parameters           ||
|-------|------------------------|
| `key` | `Key`: the key. <br /> |

|                                                                             Throws                                                                             ||
|--------------------------------------------------------------------------------------------------|--------------------------------------------------------------|
| [InvalidKeyException](https://developer.android.com/reference/java/security/InvalidKeyException) | if the given key is inappropriate for initializing this MAC. |

### reset

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void reset ()
```

Resets this`Mac`object.

A call to this method resets this`Mac`object to the state it was in when previously initialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`. That is, the object is reset and available to generate another MAC from the same key, if desired, via new calls to`update`and`doFinal`. (In order to reuse this`Mac`object with a different key, it must be reinitialized via a call to`init(Key)`or`init(Key, AlgorithmParameterSpec)`.

<br />

### update

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void update (byte[] input)
```

Processes the given array of bytes.

<br />

|                         Parameters                          ||
|---------|----------------------------------------------------|
| `input` | `byte`: the array of bytes to be processed. <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |

### update

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void update (byte[] input, 
                int offset, 
                int len)
```

Processes the first`len`bytes in`input`, starting at`offset`inclusive.

<br />

|                             Parameters                              ||
|----------|-----------------------------------------------------------|
| `input`  | `byte`: the input buffer. <br />                          |
| `offset` | `int`: the offset in`input`where the input starts. <br /> |
| `len`    | `int`: the number of bytes to process. <br />             |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |

### update

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void update (ByteBuffer input)
```

Processes`input.remaining()`bytes in the ByteBuffer`input`, starting at`input.position()`. Upon return, the buffer's position will be equal to its limit; its limit will not have changed.

<br />

|                  Parameters                  ||
|---------|-------------------------------------|
| `input` | `ByteBuffer`: the ByteBuffer <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |

### update

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public final void update (byte input)
```

Processes the given byte.

<br />

|                       Parameters                        ||
|---------|------------------------------------------------|
| `input` | `byte`: the input byte to be processed. <br /> |

|                                                                 Throws                                                                  ||
|--------------------------------------------------------------------------------------------------|---------------------------------------|
| [IllegalStateException](https://developer.android.com/reference/java/lang/IllegalStateException) | if this`Mac`has not been initialized. |