PHP Classes

File: docs/HmacHashFactory.md

Recommend this page to a friend!
  Classes of Kjell-Inge Gustafsson  >  PHP OpenSSL Toolbox  >  docs/HmacHashFactory.md  >  Download  
File: docs/HmacHashFactory.md
Role: Auxiliary data
Content type: text/markdown
Description: Auxiliary data
Class: PHP OpenSSL Toolbox
Use SSL certificates to process data with OpenSSL
Author: By
Last change:
Date: 1 year ago
Size: 2,341 bytes
 

Contents

Class file image Download

HmacHashFactory Class

The class has only static methods.

HmacHashFactory::assertAlgorithm( algorithm )
Assert algorithm using 1. hash_hmac_algos (if exist), 2. hash_algos

algorithm    string

throws InvalidArgumentException on error
return string
static method

HmacHashFactory::getDigestHash( algorithm, data, secret, rawOutput = false )
Return a keyed hash value using the HMAC method, applied on (string) argument

algorithm    string
data         string
secret       string
rawOutput    bool
               default false

return string     keyed hash value using the HMAC method, applied on (string) argument
throws InvalidArgumentException on error
static method

HmacHashFactory::getDigestHashFromFile( algorithm, fileName, secret, rawOutput = false )
Return a keyed hash value using the HMAC method, applied on contents of a given file

algorithm    string
fileName     string  
               URL describing location of file to be hashed; Supports fopen wrappers.
secret       string
rawOutput    bool
               default false

return string
throws InvalidArgumentException on error
static method

HmacHashFactory::hashEquals( expected, actual )
expected     string 
actual       string 

return bool    true if hashes match
static method

HmacHashFactory::oauth_totp( key [, time [, digits [, algorithm ]]] )
Return HMAC-based One-Time Password (HOTP)
This function implements the algorithm outlined in RFC 6238 for Time-Based One-Time Passwords

key          string
               the string to use for the HMAC key
time         mixed
               a value that reflects a time, default (unix) time()
digits       int
               the desired length of the OTP, default 8
algorithm    string
               default 'sha256'

return string       the generated OTP
throws InvalidArgumentException on error
static method

Usage and examples

Please review test/HmacHashFactoryTest.php

getDigestHash
getDigestHashFromFile
hashEquals
assertAlgorithm
getDigestHashFromFile exceptions
oauth_totp

[return to docs][return to README]

For more information send a message to info at phpclasses dot org.