[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/phpseclib/ -> Crypt_Hash.php (summary)

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: MMVII Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://phpseclib.sourceforge.net
File Size: 823 lines (28 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

Crypt_Hash:: (15 methods):
  __construct()
  setKey()
  setHash()
  hash()
  getLength()
  _md5()
  _sha1()
  _md2()
  _sha256()
  _sha512()
  _rightRotate()
  _rightShift()
  _not()
  _add()
  _string_shift()


Class: Crypt_Hash  - X-Ref

Pure-PHP implementations of keyed-hash message authentication codes (HMACs) and various cryptographic hashing functions.

__construct($hash = 'sha1')   X-Ref
Default Constructor.

param: optional String $hash
return: Crypt_Hash

setKey($key = false)   X-Ref
Sets the key for HMACs

Keys can be of any length.

param: optional String $key

setHash($hash)   X-Ref
Sets the hash function.

param: String $hash

hash($text)   X-Ref
Compute the HMAC.

param: String $text
return: String

getLength()   X-Ref
Returns the hash length (in bytes)

return: Integer

_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

param: Integer $int
param: Integer $amt
see: _sha256()
return: Integer

_rightShift($int, $amt)   X-Ref
Right Shift

param: Integer $int
param: Integer $amt
see: _sha256()
return: Integer

_not($int)   X-Ref
Not

param: Integer $int
see: _sha256()
return: Integer

_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.  Math_BigInteger() could be used but this should be faster.

param: Integer $...
see: _sha256()
return: Integer

_string_shift(&$string, $index = 1)   X-Ref
String Shift

Inspired by array_shift

param: String $string
param: optional Integer $index
return: String