PlatformDigest

interface PlatformDigest<D : Digest<D>>(source)

PlatformDigest is a platform specific implementation of Digest using PlatformData in place of ByteArray for easier direct native integration.

Digests are secure one-way hash functions that take arbitrary-sized data and output a fixed-length hash value.

A PlatformDigest object starts out initialized. The data is processed through it using the update methods. At any point reset can be called to reset the digest. Once all the data to be updated has been updated, one of the digest methods should be called to complete the hash computation.

The digest method can be called once for a given number of updates. After digest has been called, the PlatformDigest object is reset to its initialized state.

val digest = ...

digest.update(toChapter1)
val tc1 = digest.copy()
val toChapter1Digest = tc1.digest()
digest.update(toChapter2)
... etc.

Properties

Link copied to clipboard
abstract val blockLength: Int

Return the "block length" for the hash function. This value is naturally defined for iterated hash functions (Merkle-Damgard). It is used in HMAC (that's what the HMAC specification names the "B" parameter).

Link copied to clipboard
abstract val digestLength: Int

Get the natural hash function output length (in bytes).

Functions

Link copied to clipboard
abstract fun copy(): PlatformDigest<D>

Clone the current state. The returned object evolves independently of this object.

Link copied to clipboard
abstract fun digest(): PlatformData
abstract fun digest(output: PlatformData, offset: Int, length: Int): Int

Completes the hash computation by performing final operations such as padding. The digest is reset after this call is made.

abstract fun digest(input: PlatformData): PlatformData

Performs a final update on the digest using the specified array of bytes, then completes the digest computation. That is, this method first calls update, passing the input array to the update method, then calls digest.

Link copied to clipboard
abstract fun reset()

Resets the digest for further use.

Link copied to clipboard
abstract override fun toString(): String

Get the display name for this function (e.g. "SHA-1" for SHA-1).

Link copied to clipboard
abstract fun update(input: PlatformData)

Updates the digest using the specified array of bytes.

abstract fun update(input: Byte)

Updates the digest using the specified byte.

abstract fun update(input: PlatformData, offset: Int, length: Int)

Updates the digest using the specified array of bytes, starting at the specified offset.