-
Notifications
You must be signed in to change notification settings - Fork 0
getAlgorithm
Retrieves the active hashing algorithm by validating the object's configured properties, falling back to global configuration settings, or defaulting to a hardcoded safe fallback.
getAlgorithm(): string
- Takes no arguments.
(string)
: Returns a string representing the validated hashing algorithm name (e.g., sha256, md5).
📌 The method determines which algorithm to return using a 3-step fallback chain:
Instance Property (
$this->algo): Checks if an algorithm is explicitly set on the object instance and verifies its availability.Global Configuration (
getConfig('algorithm')): If the instance property is invalid or not set, it attempts to load the default algorithm from the configuration and validates it.Hardcoded Fallback (
'sha256'): If both of the above checks fail or are invalid, it defaults to returning'sha256'.
$sec->getAlgorithm() = 'sha256'
| Config Key | Default Value | Allowed Values | Description |
|---|---|---|---|
| algorithm | sha256 | string (See: ) | Default hashing algorithm. |
- No debug errors.
algorithmExists | listAlgorithms | setAlgorithm