Sha1

class Sha1

Incremental SHA-1 (FIPS 180-1). Pure-Kotlin port of libtorrent's bundled public-domain SHA-1 (src/sha1.cpp). libtorrent uses this when no platform crypto backend (CommonCrypto, CNG, libcrypto, gcrypt) is available, which is also our situation in commonMain.

Byte-for-byte compatible with the reference: verified against the FIPS test vectors ("abc", the 56-char string, and a million 'a's) in the test suite.

This is not a cryptographically hardened implementation. BitTorrent uses SHA-1 as a content checksum (info-hashes, piece hashes), not for security.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Finish and return the 20-byte digest. The instance must not be reused after.

Link copied to clipboard
fun update(b: Byte): Sha1

fun update(data: ByteArray, offset: Int = 0, length: Int = data.size - offset): Sha1

Feed length bytes from data starting at offset. Returns this for chaining.