PHP Class phpseclib\Crypt\Hash

Author: Jim Wigginton ([email protected])
Show file Open project: phpseclib/phpseclib Class Usage Examples

Public Properties

Property Type Description
$hash string Hash Algorithm
$hashParam integer Hash Parameter
$initial array Used only for sha512/*
$ipad string Used only for sha512/*
$key string Key
$length integer Byte-length of hash output (Internal HMAC)
$opad string Used only for sha512/*

Public Methods

Method Description
__construct ( string $hash = 'sha256' ) Default Constructor.
_sha512 ( string $m, $hash ) Pure-PHP implementation of SHA512
getBlockLength ( ) : integer Returns the block length (in bits)
getBlockLengthInBytes ( ) : integer Returns the block length (in bytes)
getHash ( ) : string Gets the hash function.
getLength ( ) : integer Returns the hash length (in bits)
getLengthInBytes ( ) : integer Returns the hash length (in bytes)
hash ( string $text ) : string Compute the HMAC.
setHash ( string $hash ) Sets the hash function.
setKey ( string $key = false ) Sets the key for HMACs

Method Details

__construct() public method

Default Constructor.
public __construct ( string $hash = 'sha256' )
$hash string

_sha512() static public method

Pure-PHP implementation of SHA512
static public _sha512 ( string $m, $hash )
$m string

getBlockLength() public method

Returns the block length (in bits)
public getBlockLength ( ) : integer
return integer

getBlockLengthInBytes() public method

Returns the block length (in bytes)
public getBlockLengthInBytes ( ) : integer
return integer

getHash() public method

As set by the constructor or by the setHash() method.
public getHash ( ) : string
return string

getLength() public method

Returns the hash length (in bits)
public getLength ( ) : integer
return integer

getLengthInBytes() public method

Returns the hash length (in bytes)
public getLengthInBytes ( ) : integer
return integer

hash() public method

Compute the HMAC.
public hash ( string $text ) : string
$text string
return string

setHash() public method

Sets the hash function.
public setHash ( string $hash )
$hash string

setKey() public method

Keys can be of any length.
public setKey ( string $key = false )
$key string

Property Details

$hash public property

Hash Algorithm
See also: self::setHash()
public string $hash
return string

$hashParam public property

Hash Parameter
See also: self::setHash()
public int $hashParam
return integer

$initial public property

Used only for sha512/*
See also: self::_sha512()
public array $initial
return array

$ipad public property

Used only for sha512/*
See also: self::hash()
public string $ipad
return string

$key public property

Key
See also: self::setKey()
public string $key
return string

$length public property

Byte-length of hash output (Internal HMAC)
See also: self::setHash()
public int $length
return integer

$opad public property

Used only for sha512/*
See also: self::hash()
public string $opad
return string