Crypt_HMAC2
[ class tree: Crypt_HMAC2 ] [ index: Crypt_HMAC2 ] [ all elements ]

Class: Crypt_HMAC2

Source Location: /Crypt_HMAC2-1.0.0/Crypt/HMAC2.php

Class Overview


Crypt_HMAC2 class


Author(s):

Version:

  • @package_version@

Copyright:

  • 2005-2007 Pádraic Brady

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 73]
Crypt_HMAC2 class

Example usage: $key = str_repeat("\xaa", 20); // insecure key only for example $data = "Hello World!"; $hmac = new Crypt_HMAC2($key, 'SHA256'); $hmacHash = $hmac->hash($data);

Supported hashing algorithms are limited by your PHP version access to the hash, mhash extensions and supported native functions like md5() and sha1().

To obtain raw binary output, set the optional second parameter of Crypt_HMAC2::hash() to Crypt_HMAC2::BINARY.

$hmacRawHash = $hmac->hash($data, Crypt_HMAC2::BINARY);



[ Top ]


Class Variables

$_hashAlgorithm =  'md5'

[line 96]

Hashing algorithm; can be the md5/sha1 functions or any algorithm name listed in the output of PHP 5.1.2+ hash_algos().
  • Access: protected

Type:   string


[ Top ]

$_hashPackFormats = array(
        'md5'        => 'H32',
        'sha1'       => 'H40'
    )

[line 115]

List of hash pack formats for each hashing algorithm supported.

Only required when hash or mhash are not available, and we are using either md5() or sha1().

  • Access: protected

Type:   array


[ Top ]

$_key =  null

[line 81]

The key to use for the hash
  • Access: protected

Type:   string


[ Top ]

$_packFormat =  null

[line 88]

pack() format to be used for current hashing method
  • Access: protected

Type:   string


[ Top ]

$_supportedHashNativeFunctions = array(
        'md5',
        'sha1',
    )

[line 103]

Supported direct hashing functions in PHP
  • Access: protected

Type:   array


[ Top ]

$_supportedMhashAlgorithms = array('adler32',' crc32', 'crc32b', 'gost', 
            'haval128', 'haval160', 'haval192', 'haval256', 'md4', 'md5', 'ripemd160', 
            'sha1', 'sha256', 'tiger', 'tiger128', 'tiger160')

[line 125]

List of algorithms supported my mhash()
  • Access: protected

Type:   array


[ Top ]



Method Detail

__construct (Constructor)   [line 141]

Crypt_HMAC2 __construct( [string $key = null], [string $hash = null])

Constructor; optionally set Key and Hash at this point
  • Access: public

Parameters:

string   $key   — 
string   $hash   — 

[ Top ]

getHashAlgorithm   [line 223]

string getHashAlgorithm( )

Return the current hashing algorithm
  • Access: public

[ Top ]

getKey   [line 172]

string getKey( )

Getter to return the currently set key
  • Access: public

[ Top ]

hash   [line 235]

string hash( string $data, [ $output = self::STRING], [bool $internal = false])

Perform HMAC and return the keyed data
  • Access: public

Parameters:

string   $data   — 
bool   $internal   —  Option to not use hash() functions for testing
   $output   — 

[ Top ]

setHashAlgorithm   [line 192]

Crypt_HMAC2 setHashAlgorithm( string $hash)

Setter for the hash method. Supports md5() and sha1() functions, and if available the hashing algorithms supported by the hash() PHP5 function or the mhash extension.

Since they are so many varied HMAC methods in PHP these days this method does a lot of checking to figure out what's available and not.

  • Access: public

Parameters:

string   $hash   — 

[ Top ]

setKey   [line 157]

Crypt_HMAC2 setKey( string $key)

Set the key to use when hashing
  • Access: public

Parameters:

string   $key   — 

[ Top ]

_digest   [line 292]

string _digest( string $hash, string $key, string $mode)

Digest method when using native functions which allows the selection of raw binary output.
  • Access: protected

Parameters:

string   $hash   — 
string   $key   — 
string   $mode   — 

[ Top ]

_getMhashDefinition   [line 275]

integer _getMhashDefinition( string $hashAlgorithm)

Method of working around the inability to use mhash constants; this will locate the Constant value of any support Hashing algorithm named in the string parameter.
  • Access: protected

Parameters:

string   $hashAlgorithm   — 

[ Top ]


Documentation generated on Mon, 11 Mar 2019 15:36:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.