Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/java/util/zip/Checksum#pubmethods)

# Checksum

` public interface Checksum `   
` `

|---|
| java.util.zip.Checksum |

Known indirect subclasses [Adler32](https://developer.android.com/reference/java/util/zip/Adler32), [CRC32](https://developer.android.com/reference/java/util/zip/CRC32), [CRC32C](https://developer.android.com/reference/java/util/zip/CRC32C) [Adler32](https://developer.android.com/reference/java/util/zip/Adler32) A class that can be used to compute the Adler-32 checksum of a data stream. [CRC32](https://developer.android.com/reference/java/util/zip/CRC32) A class that can be used to compute the CRC-32 of a data stream. [CRC32C](https://developer.android.com/reference/java/util/zip/CRC32C) A class that can be used to compute the CRC-32C of a data stream.   

*** ** * ** ***

An interface representing a data checksum.

## Summary

| ### Public methods ||
|---|---|
| ` abstract long` | ` https://developer.android.com/reference/java/util/zip/Checksum#getValue()() ` Returns the current checksum value. |
| ` abstract void` | ` https://developer.android.com/reference/java/util/zip/Checksum#reset()() ` Resets the checksum to its initial value. |
| ` default void` | ` https://developer.android.com/reference/java/util/zip/Checksum#update(byte[])(byte[] b) ` Updates the current checksum with the specified array of bytes. |
| ` default void` | ` https://developer.android.com/reference/java/util/zip/Checksum#update(java.nio.ByteBuffer)(https://developer.android.com/reference/java/nio/ByteBuffer buffer) ` Updates the current checksum with the bytes from the specified buffer. |
| ` abstract void` | ` https://developer.android.com/reference/java/util/zip/Checksum#update(byte[],%20int,%20int)(byte[] b, int off, int len) ` Updates the current checksum with the specified array of bytes. |
| ` abstract void` | ` https://developer.android.com/reference/java/util/zip/Checksum#update(int)(int b) ` Updates the current checksum with the specified byte. |

## Public methods

### getValue

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

```
public abstract long getValue ()
```

Returns the current checksum value.

<br />

| Returns ||
|---|---|
| `long` | the current checksum value <br /> |

### reset

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

```
public abstract void reset ()
```

Resets the checksum to its initial value.

<br />

### update

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

```
public void update (byte[] b)
```

Updates the current checksum with the specified array of bytes.

<br />

##### Implementation Requirements:

- This default implementation is equal to calling `update(b, 0, b.length)`.

| Parameters ||
|---|---|
| `b` | `byte`: the array of bytes to update the checksum with <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `b` is `null` |

### update

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

```
public void update (ByteBuffer buffer)
```

Updates the current checksum with the bytes from the specified buffer. The checksum is updated with the remaining bytes in the buffer, starting at the buffer's position. Upon return, the buffer's position will be updated to its limit; its limit will not have been changed.

<br />

##### API Note:

- For best performance with DirectByteBuffer and other ByteBuffer implementations without a backing array implementers of this interface should override this method.

##### Implementation Requirements:

- The default implementation has the following behavior.  
  For ByteBuffers backed by an accessible byte array.

      update(buffer.array(),
             buffer.position() + buffer.arrayOffset(),
             buffer.remaining());

  For ByteBuffers not backed by an accessible byte array.

      byte[] b = new byte[Math.min(buffer.remaining(), 4096)];
      while (buffer.hasRemaining()) {
          int length = Math.min(buffer.remaining(), b.length);
          buffer.get(b, 0, length);
          update(b, 0, length);
      }

| Parameters ||
|---|---|
| `buffer` | `ByteBuffer`: the ByteBuffer to update the checksum with <br /> |

| Throws ||
|---|---|
| `https://developer.android.com/reference/java/lang/NullPointerException` | if `buffer` is `null` |

### update

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

```
public abstract void update (byte[] b, 
                int off, 
                int len)
```

Updates the current checksum with the specified array of bytes.

<br />

| Parameters ||
|---|---|
| `b` | `byte`: the byte array to update the checksum with <br /> |
| `off` | `int`: the start offset of the data <br /> |
| `len` | `int`: the number of bytes to use for the update <br /> |

### update

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

```
public abstract void update (int b)
```

Updates the current checksum with the specified byte.

<br />

| Parameters ||
|---|---|
| `b` | `int`: the byte to update the checksum with <br /> |