update

abstract fun update(b: Int)

Updates the current checksum with the specified byte.

Parameters

b

the byte (0..255) to update the checksum with


open fun update(b: ByteArray)

Updates the current checksum with the specified array of bytes.

This default implementation is equivalent to calling update with the full array.

Parameters

b

the array of bytes to update the checksum with

Throws


abstract fun update(b: ByteArray, off: Int, len: Int)

Updates the current checksum with a portion of an array of bytes.

Parameters

b

the byte array to update the checksum with

off

the start offset of the data

len

the number of bytes to use for the update


open fun update(buffer: Buffer)

Updates the current checksum with the bytes from the specified buffer.

The checksum is updated with the remaining bytes in the buffer. Upon return, the buffer’s read position will have advanced to its end.

For example, the implementation reads chunks (up to 4096 bytes at a time) from the buffer and updates the checksum:

fun update(buffer: Buffer) {
while (buffer.size > 0L) {
// Process in chunks of up to 4096 bytes.
val chunkSize = min(buffer.size.toInt(), 4096)
val temp = ByteArray(chunkSize)
buffer.read(temp, 0, chunkSize) // advances the buffer's read position
update(temp, 0, chunkSize)
}
}

Parameters

buffer

the Buffer to update the checksum with

Throws


open fun update(byteBuffer: ByteBuffer)