[ Index ] |
PHP Cross Reference of DokuWiki |
[Source view] [Print] [Project Stats]
Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions. Uses hash() or mhash() if available and an internal implementation, otherwise. Currently supports the following:
Author: | Jim Wigginton |
Copyright: | 2007 Jim Wigginton |
License: | http://www.opensource.org/licenses/mit-license.html MIT License |
Link: | http://phpseclib.sourceforge.net |
File Size: | 893 lines (29 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
Hash:: (17 methods):
__construct()
setKey()
_computeKey()
getHash()
setHash()
hash()
getLength()
_md5()
_sha1()
_md2()
_sha256()
_sha512()
_rightRotate()
_rightShift()
_not()
_add()
_string_shift()
__construct($hash = 'sha1') X-Ref |
Default Constructor. return: \phpseclib\Crypt\Hash param: string $hash |
setKey($key = false) X-Ref |
Sets the key for HMACs Keys can be of any length. param: string $key |
_computeKey() X-Ref |
Pre-compute the key used by the HMAC Quoting http://tools.ietf.org/html/rfc2104#section-2, "Applications that use keys longer than B bytes will first hash the key using H and then use the resultant L byte string as the actual key to HMAC." As documented in https://www.reddit.com/r/PHP/comments/9nct2l/symfonypolyfill_hash_pbkdf2_correct_fix_for/ when doing an HMAC multiple times it's faster to compute the hash once instead of computing it during every call |
getHash() X-Ref |
Gets the hash function. As set by the constructor or by the setHash() method. return: string |
setHash($hash) X-Ref |
Sets the hash function. param: string $hash |
hash($text) X-Ref |
Compute the HMAC. return: string param: string $text |
getLength() X-Ref |
Returns the hash length (in bytes) return: int |
_md5($m) X-Ref |
Wrapper for MD5 param: string $m |
_sha1($m) X-Ref |
Wrapper for SHA1 param: string $m |
_md2($m) X-Ref |
Pure-PHP implementation of MD2 See {@link http://tools.ietf.org/html/rfc1319 RFC1319}. param: string $m |
_sha256($m) X-Ref |
Pure-PHP implementation of SHA256 See {@link http://en.wikipedia.org/wiki/SHA_hash_functions#SHA-256_.28a_SHA-2_variant.29_pseudocode SHA-256 (a SHA-2 variant) pseudocode - Wikipedia}. param: string $m |
_sha512($m) X-Ref |
Pure-PHP implementation of SHA384 and SHA512 param: string $m |
_rightRotate($int, $amt) X-Ref |
Right Rotate return: int param: int $int param: int $amt see: self::_sha256() |
_rightShift($int, $amt) X-Ref |
Right Shift return: int param: int $int param: int $amt see: self::_sha256() |
_not($int) X-Ref |
Not return: int param: int $int see: self::_sha256() |
_add() X-Ref |
Add _sha256() adds multiple unsigned 32-bit integers. Since PHP doesn't support unsigned integers and since the possibility of overflow exists, care has to be taken. BigInteger could be used but this should be faster. return: int see: self::_sha256() |
_string_shift(&$string, $index = 1) X-Ref |
String Shift Inspired by array_shift return: string param: string $string param: int $index |