core/model/modx/hashing/modhashing.class.php
This file contains the modHashing service class definition and the modHash abstract implementation class.
- Package
- modx
- Subpackage
- hashing
\modHash
Defines the interface for a modHash implementation.
- Children
- \modPBKDF2
- \modMD5
- Abstract
- Implement a derivative of this class to define an actual hash algorithm implementation.
Properties
\modHashing
$host= 'null'
A reference to the modHashing service hosting this modHash instance.
null
Details- Type
- \modHashing
Methods
__construct(
\modHashing $host, array | null $options
=
array()
)
:
\modHash
Constructs a new instance of the modHash class.
Name | Type | Description |
---|---|---|
$host | \modHashing | A reference to the modHashing instance |
$options | array | null | An optional array of configuration options |
Type | Description |
---|---|
\modHash | A new derivative instance of the modHash class |
getOption(
string $key, array | null $options
=
null, mixed $default
=
null
)
:
mixed
Get an option for this modHash implementation
Searches for local options and then prefixes keys with hashing_ to look for MODX System Settings.
Name | Type | Description |
---|---|---|
$key | string | The option key to get a value for. |
$options | array | null | An optional array of options to look in first. |
$default | mixed | An optional default value to return if no value is set. |
Type | Description |
---|---|
mixed | The option value or the specified default if not found. |
hash(
string $string, array $options
=
array()
)
:
mixed
Generate a hash of the given string using the provided options.
Name | Type | Description |
---|---|---|
$string | string | A string to generate a secure hash from. |
$options | array | An array of options to be passed to the hash implementation. |
Type | Description |
---|---|
mixed | The hash result or false on failure. |
- Abstract
\modHashing
The modX hashing service class.
Properties
array
$_hashes= 'array()'
An array of loaded modHash implementations.
array()
Details- Type
- array
\xPDO
$modx= 'null'
A reference to an xPDO instance communicating with this service instance.
Though this is typically a modX instance, an xPDO instance must work for new installs.
null
Details- Type
- \xPDO
Methods
__construct(
\xPDO $modx, array | null $options
=
array()
)
:
void
Constructs a new instance of the modHashing service class.
Name | Type | Description |
---|---|---|
$modx | \xPDO | &$modx A reference to an modX (or xPDO) instance. |
$options | array | null | An array of options for the hashing service. |
getHash(
string $key, string $class, array | null $options
=
array()
)
:
\modHash | null
Get a hash implementation instance.
The implementation is made available as a member variable of the modHashing service.
Name | Type | Description |
---|---|---|
$key | string | A key string identifying the instance; must be a valid PHP variable name. |
$class | string | A valid fully-qualified modHash derivative class name |
$options | array | null | An optional array of hash options. |
Type | Description |
---|---|
\modHash | null | A reference to a modHash instance or null if could not be instantiated. |
getOption(
string $key, array | null $options
=
null, mixed $default
=
null
)
:
mixed
Get an option for the MODX hashing service.
Searches for local options and then prefixes keys with encrypt_ to look for MODX System Settings.
Name | Type | Description |
---|---|---|
$key | string | The option key to get a value for. |
$options | array | null | An optional array of options to look in first. |
$default | mixed | An optional default value to return if no value is set. |
Type | Description |
---|---|
mixed | The option value or the specified default if not found. |