phpseclib API Documentation
Class

phpseclib\Crypt\Hash

class Hash

Properties

int $hashParam Hash Parameter
int $length Byte-length of hash output (Internal HMAC)
string $hash Hash Algorithm
string $key Key

Methods

__construct(string $hash = 'sha256')

Default Constructor.

setKey(string $key = false)

Sets the key for HMACs

string getHash()

Gets the hash function.

setHash(string $hash)

Sets the hash function.

string hash(string $text)

Compute the HMAC.

int getLength()

Returns the hash length (in bytes)

Details

at line 88
public __construct(string $hash = 'sha256')

Default Constructor.

Parameters

string $hash

at line 101
public setKey(string $key = false)

Sets the key for HMACs

Keys can be of any length.

Parameters

string $key

at line 114
public string getHash()

Gets the hash function.

As set by the constructor or by the setHash() method.

Return Value

string

at line 125
public setHash(string $hash)

Sets the hash function.

Parameters

string $hash

at line 184
public string hash(string $text)

Compute the HMAC.

Parameters

string $text

Return Value

string

at line 201
public int getLength()

Returns the hash length (in bytes)

Return Value

int