Stay organized with collections
Save and categorize content based on your preferences.
Checksum
interface Checksum
Known Direct Subclasses
Adler32 |
A class that can be used to compute the Adler-32 checksum of a data stream.
|
CRC32 |
A class that can be used to compute the CRC-32 of a data stream.
|
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 |
Returns the current checksum value.
|
abstract Unit |
Resets the checksum to its initial value.
|
open Unit |
Updates the current checksum with the specified array of bytes.
|
abstract Unit |
Updates the current checksum with the specified array of bytes.
|
abstract Unit |
Updates the current checksum with the specified byte.
|
open Unit |
Updates the current checksum with the bytes from the specified buffer.
|
Public methods
getValue
abstract fun getValue(): Long
Returns the current checksum value.
Return |
Long |
the current checksum value |
reset
abstract fun reset(): Unit
Resets the checksum to its initial value.
update
open fun update(b: ByteArray!): Unit
Updates the current checksum with the specified array of bytes.
Parameters |
b |
ByteArray!: the array of bytes to update the checksum with |
Exceptions |
java.lang.NullPointerException |
if b is null |
update
abstract fun update(
b: ByteArray!,
off: Int,
len: Int
): Unit
Updates the current checksum with the specified array of bytes.
Parameters |
b |
ByteArray!: the byte array to update the checksum with |
off |
Int: the start offset of the data |
len |
Int: the number of bytes to use for the update |
update
abstract fun update(b: Int): Unit
Updates the current checksum with the specified byte.
Parameters |
b |
Int: the byte to update the checksum with |
update
open fun update(buffer: ByteBuffer!): Unit
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.
Parameters |
buffer |
ByteBuffer!: the ByteBuffer to update the checksum with |
Exceptions |
java.lang.NullPointerException |
if buffer is null |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# Checksum\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nChecksum\n========\n\n```\ninterface Checksum\n```\n\n|-----------------------------|\n| [java.util.zip.Checksum](#) |\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Known Direct Subclasses [Adler32](/reference/kotlin/java/util/zip/Adler32), [CRC32](/reference/kotlin/java/util/zip/CRC32), [CRC32C](/reference/kotlin/java/util/zip/CRC32C) |----------------------------------------------------|-----------------------------------------------------------------------------| | [Adler32](/reference/kotlin/java/util/zip/Adler32) | A class that can be used to compute the Adler-32 checksum of a data stream. | | [CRC32](/reference/kotlin/java/util/zip/CRC32) | A class that can be used to compute the CRC-32 of a data stream. | | [CRC32C](/reference/kotlin/java/util/zip/CRC32C) | A class that can be used to compute the CRC-32C of a data stream. | |\n\nAn interface representing a data checksum.\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | [getValue](#getValue())`()` Returns the current checksum value. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [reset](#reset())`()` Resets the checksum to its initial value. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [update](#update(kotlin.ByteArray))`(`b:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`)` Updates the current checksum with the specified array of bytes. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [update](#update(kotlin.ByteArray,%20kotlin.Int,%20kotlin.Int))`(`b:` `[ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!`, `off:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`, `len:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Updates the current checksum with the specified array of bytes. |\n| abstract [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [update](#update(kotlin.Int))`(`b:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Updates the current checksum with the specified byte. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [update](#update(java.nio.ByteBuffer))`(`buffer:` `[ByteBuffer](../../nio/ByteBuffer.html#)!`)` Updates the current checksum with the bytes from the specified buffer. |\n\nPublic methods\n--------------\n\n### getValue\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun getValue(): Long\n```\n\nReturns the current checksum value.\n\n| Return ||\n|------------------------------------------------------------------------------|----------------------------|\n| [Long](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-long/index.html) | the current checksum value |\n\n### reset\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun reset(): Unit\n```\n\nResets the checksum to its initial value. \n\n### update\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun update(b: ByteArray!): Unit\n```\n\nUpdates the current checksum with the specified array of bytes.\n\n| Parameters ||\n|-----|------------------------------------------------------------------------------------------------------------------------------------------|\n| `b` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: the array of bytes to update the checksum with |\n\n| Exceptions ||\n|----------------------------------|------------------|\n| `java.lang.NullPointerException` | if `b` is `null` |\n\n### update\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun update(\n b: ByteArray!, \n off: Int, \n len: Int\n): Unit\n```\n\nUpdates the current checksum with the specified array of bytes.\n\n| Parameters ||\n|-------|--------------------------------------------------------------------------------------------------------------------------------------|\n| `b` | [ByteArray](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-byte-array/index.html)!: the byte array to update the checksum with |\n| `off` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the start offset of the data |\n| `len` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the number of bytes to use for the update |\n\n### update\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nabstract fun update(b: Int): Unit\n```\n\nUpdates the current checksum with the specified byte.\n\n| Parameters ||\n|-----|------------------------------------------------------------------------------------------------------------------|\n| `b` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): the byte to update the checksum with |\n\n### update\n\nAdded in [API level 34](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun update(buffer: ByteBuffer!): Unit\n```\n\nUpdates 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.\n\n| Parameters ||\n|----------|---------------------------------------------------------------------------------------|\n| `buffer` | [ByteBuffer](../../nio/ByteBuffer.html#)!: the ByteBuffer to update the checksum with |\n\n| Exceptions ||\n|----------------------------------|-----------------------|\n| `java.lang.NullPointerException` | if `buffer` is `null` |"]]