Documentation

TreeHash
in package
implements HashInterface

Encapsulates the creation of a tree hash from streamed data

Interfaces, Classes and Traits

HashInterface
Interface that allows implementing various incremental hashes.

Table of Contents

EMPTY_HASH  = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'
MB  = 1048576
$algorithm  : string
$buffer  : string
$checksums  : array<string|int, mixed>
$hash  : string
__construct()  : mixed
addChecksum()  : self
Add a checksum to the tree hash directly
complete()  : string
Finalizes the incremental hash and returns the resulting digest.
reset()  : mixed
Removes all data from the hash, effectively starting a new hash.
update()  : mixed
Adds data to the hash.

Constants

EMPTY_HASH

public mixed EMPTY_HASH = 'e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855'

Properties

$algorithm

private string $algorithm

Algorithm used for hashing.

$buffer

private string $buffer

Buffered data that has not yet been hashed.

$checksums

private array<string|int, mixed> $checksums = []

Binary checksums from which the tree hash is derived.

$hash

private string $hash

Resulting hash in binary form.

Methods

__construct()

public __construct([mixed $algorithm = 'sha256' ]) : mixed
Parameters
$algorithm : mixed = 'sha256'
Return values
mixed —

addChecksum()

Add a checksum to the tree hash directly

public addChecksum(string $checksum[, bool $inBinaryForm = false ]) : self
Parameters
$checksum : string

The checksum to add

$inBinaryForm : bool = false

TRUE if checksum is in binary form

Tags
throws
LogicException

if the root tree hash is already calculated

Return values
self —

complete()

Finalizes the incremental hash and returns the resulting digest.

public complete() : string
Return values
string —

reset()

Removes all data from the hash, effectively starting a new hash.

public reset() : mixed
Return values
mixed —

update()

Adds data to the hash.

public update(mixed $data) : mixed
Parameters
$data : mixed

Data to add to the hash

Tags
throws
LogicException

if the root tree hash is already calculated

Return values
mixed —

Search results