HashService
class HashService (View source)
A hash service which should be used to generate and validate hashes.
Properties
protected string | $encryptionKey | A private, unique key used for encryption tasks |
|
protected array | $passwordHashingStrategies | ||
protected array | $strategySettings | ||
protected ObjectManagerInterface | $objectManager | ||
protected StringFrontend | $cache |
Methods
Injects the settings of the package this controller belongs to.
Generate a hash (HMAC) for a given string
Appends a hash (HMAC) to a given string and returns the result
Tests if a string $string matches the HMAC given by $hash.
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.
Hash a password using the configured password hashing strategy
Validate a hashed password using the configured password hashing strategy
Get a password hashing strategy
Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new encryption key will be generated and stored in the cache.
Details
void
injectSettings(array $settings)
Injects the settings of the package this controller belongs to.
string
generateHmac(string $string)
Generate a hash (HMAC) for a given string
string
appendHmac(string $string)
Appends a hash (HMAC) to a given string and returns the result
bool
validateHmac(string $string, string $hmac)
Tests if a string $string matches the HMAC given by $hash.
string
validateAndStripHmac(string $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.
string
hashPassword(string $password, string $strategyIdentifier = 'default')
Hash a password using the configured password hashing strategy
bool
validatePassword(string $password, string $hashedPasswordAndSalt)
Validate a hashed password using the configured password hashing strategy
protected PasswordHashingStrategyInterface[]
getPasswordHashingStrategyAndIdentifier(string $strategyIdentifier = 'default')
Get a password hashing strategy
protected string
getEncryptionKey()
Returns the encryption key from the persistent cache or Data/Persistent directory. If none exists, a new encryption key will be generated and stored in the cache.