TYPO3  7.6
Public Member Functions | List of all members
HashService Class Reference
Inheritance diagram for HashService:
SingletonInterface

Public Member Functions

 generateHmac ($string)
 
 appendHmac ($string)
 
 validateHmac ($string, $hmac)
 
 validateAndStripHmac ($string)
 

Detailed Description

A hash service which should be used to generate and validate hashes.

It will use some salt / encryption key in the future.

http://www.gnu.org/licenses/lgpl.html GNU Lesser Public License, version 3 or later

Definition at line 24 of file HashService.php.

Member Function Documentation

appendHmac (   $string)

Appends a hash (HMAC) to a given string and returns the result

Parameters
string$stringThe string for which a hash should be generated
Returns
string The original string with HMAC of the string appended
See Also
generateHmac()
Todo:
Mark as API once it is more stable

Definition at line 53 of file HashService.php.

References HashService\generateHmac().

generateHmac (   $string)

Generate a hash (HMAC) for a given string

Parameters
string$stringThe string for which a hash should be generated
Returns
string The hash of the string
Exceptions
\TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationExceptionif something else than a string was given as parameter

Definition at line 33 of file HashService.php.

References $GLOBALS.

Referenced by HashService\appendHmac(), and HashService\validateHmac().

validateAndStripHmac (   $string)

Tests if the last 40 characters of a given string $string matches the HMAC of the rest of the string and, if true, returns the string without the HMAC. In case of a HMAC validation error, an exception is thrown.

Parameters
string$stringThe string with the HMAC appended (in the format 'string<HMAC>')
Returns
string the original string without the HMAC, if validation was successful
See Also
validateHmac()
Exceptions
\TYPO3\CMS\Extbase\Security\Exception\InvalidArgumentForHashGenerationExceptionif the given string is not well-formatted
\TYPO3\CMS\Extbase\Security\Exception\InvalidHashExceptionif the hash did not fit to the data.
Todo:
Mark as API once it is more stable

Definition at line 84 of file HashService.php.

References HashService\validateHmac().

validateHmac (   $string,
  $hmac 
)

Tests if a string $string matches the HMAC given by $hash.

Parameters
string$stringThe string which should be validated
string$hmacThe hash of the string
Returns
bool TRUE if string and hash fit together, FALSE otherwise.

Definition at line 66 of file HashService.php.

References HashService\generateHmac().

Referenced by HashService\validateAndStripHmac().