Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct (Random $random, DeploymentConfig $deploymentConfig) | |
validateCipher ($version) | |
getHash ($password, $salt=false, $version=self::HASH_VERSION_LATEST) | |
hash ($data, $version=self::HASH_VERSION_LATEST) | |
validateHash ($password, $hash) | |
isValidHash ($password, $hash) | |
validateHashVersion ($hash, $validateCount=false) | |
encrypt ($data) | |
encryptWithFastestAvailableAlgorithm ($data) | |
decrypt ($data) | |
validateKey ($key) | |
setNewKey ($key) | |
exportKeys () | |
![]() | |
getHash ($password, $salt=false) | |
hash ($data) | |
Data Fields | |
const | HASH_VERSION_MD5 = 0 |
const | HASH_VERSION_SHA256 = 1 |
const | HASH_VERSION_LATEST = 1 |
const | DEFAULT_SALT_LENGTH = 32 |
const | PASSWORD_HASH = 0 |
const | PASSWORD_SALT = 1 |
const | PASSWORD_VERSION = 2 |
const | PARAM_CRYPT_KEY = 'crypt/key' |
const | CIPHER_BLOWFISH = 0 |
const | CIPHER_RIJNDAEL_128 = 1 |
const | CIPHER_RIJNDAEL_256 = 2 |
const | CIPHER_AEAD_CHACHA20POLY1305 = 3 |
const | CIPHER_LATEST = 3 |
const | DELIMITER = ':' |
Protected Attributes | |
$cipher = self::CIPHER_LATEST | |
$keyVersion | |
$keys = [] | |
Class Encryptor provides basic logic for hashing strings and encrypting/decrypting misc data
Definition at line 21 of file Encryptor.php.
__construct | ( | Random | $random, |
DeploymentConfig | $deploymentConfig | ||
) |
Encryptor constructor.
Random | $random | |
DeploymentConfig | $deploymentConfig |
Definition at line 123 of file Encryptor.php.
decrypt | ( | $data | ) |
Look for key and crypt versions in encrypted data before decrypting
Unsupported/unspecified key version silently fallback to the oldest we have Unsupported cipher versions eventually throw exception Unspecified cipher version fallback to the oldest we support
string | $data |
Implements EncryptorInterface.
Definition at line 319 of file Encryptor.php.
encrypt | ( | $data | ) |
Prepend key and cipher versions to encrypted data after encrypting
string | $data |
Implements EncryptorInterface.
Definition at line 283 of file Encryptor.php.
encryptWithFastestAvailableAlgorithm | ( | $data | ) |
Encrypt data using the fastest available algorithm
string | $data |
Definition at line 298 of file Encryptor.php.
exportKeys | ( | ) |
getHash | ( | $password, | |
$salt = false , |
|||
$version = self::HASH_VERSION_LATEST |
|||
) |
Definition at line 162 of file Encryptor.php.
array map of password hash | ( | $data, | |
$version = self::HASH_VERSION_LATEST |
|||
) |
Definition at line 187 of file Encryptor.php.
isValidHash | ( | $password, | |
$hash | |||
) |
Validate hash against hashing method (with or without salt)
string | $password | |
string | $hash |
Implements EncryptorInterface.
Definition at line 203 of file Encryptor.php.
setNewKey | ( | $key | ) |
Attempt to append new key & version
string | $key |
Definition at line 383 of file Encryptor.php.
validateCipher | ( | $version | ) |
Check whether specified cipher version is supported
Returns matched supported version or throws exception
int | $version |
Definition at line 143 of file Encryptor.php.
validateHash | ( | $password, | |
$hash | |||
) |
Validate hash against hashing method (with or without salt)
string | $password | |
string | $hash |
Implements EncryptorInterface.
Definition at line 195 of file Encryptor.php.
validateHashVersion | ( | $hash, | |
$validateCount = false |
|||
) |
Validate hashing algorithm version
string | $hash | |
bool | $validateCount |
Implements EncryptorInterface.
Definition at line 220 of file Encryptor.php.
validateKey | ( | $key | ) |
Validate key contains only allowed characters
string | null | $key | NULL value means usage of the default key specified on constructor |
Implements EncryptorInterface.
Definition at line 369 of file Encryptor.php.
|
protected |
Definition at line 97 of file Encryptor.php.
|
protected |
Definition at line 111 of file Encryptor.php.
|
protected |
Definition at line 104 of file Encryptor.php.
const CIPHER_AEAD_CHACHA20POLY1305 = 3 |
Definition at line 65 of file Encryptor.php.
const CIPHER_BLOWFISH = 0 |
#+ Cipher versions
Definition at line 59 of file Encryptor.php.
const CIPHER_LATEST = 3 |
Definition at line 67 of file Encryptor.php.
const CIPHER_RIJNDAEL_128 = 1 |
Definition at line 61 of file Encryptor.php.
const CIPHER_RIJNDAEL_256 = 2 |
Definition at line 63 of file Encryptor.php.
const DEFAULT_SALT_LENGTH = 32 |
Default length of salt in bytes
Definition at line 41 of file Encryptor.php.
const DELIMITER = ':' |
#- Default hash string delimiter
Definition at line 73 of file Encryptor.php.
const HASH_VERSION_LATEST = 1 |
Key of latest used algorithm
Definition at line 36 of file Encryptor.php.
const HASH_VERSION_MD5 = 0 |
Key of md5 algorithm
Definition at line 26 of file Encryptor.php.
const HASH_VERSION_SHA256 = 1 |
Key of sha256 algorithm
Definition at line 31 of file Encryptor.php.
const PARAM_CRYPT_KEY = 'crypt/key' |
#- Array key of encryption key in deployment config
Definition at line 54 of file Encryptor.php.
const PASSWORD_HASH = 0 |
#+ Exploded password hash keys
Definition at line 46 of file Encryptor.php.
const PASSWORD_SALT = 1 |
Definition at line 47 of file Encryptor.php.
const PASSWORD_VERSION = 2 |
Definition at line 48 of file Encryptor.php.