acf_encrypt()
Encrypts a string using PHP. https://bhoover.com/using-php-openssl_encrypt-openssl_decrypt-encrypt-decrypt-data/
Хуков нет.
Возвращает
string|false. Encrypted string, or false if encryption fails.
Использование
acf_encrypt( $data );
- $data(строка)
- The data to encrypt.
По умолчанию:''
Список изменений
| С версии 5.5.8 | Введена. |
Код acf_encrypt() acf encrypt ACF 6.8.8
function acf_encrypt( $data = '' ) {
if ( ! function_exists( 'openssl_encrypt' ) ) {
return false;
}
$key = wp_hash( 'acf_encrypt' );
$mac_key = wp_hash( 'acf_encrypt_mac' );
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
$encrypted_data = openssl_encrypt( $data, 'aes-256-cbc', $key, 0, $iv );
$payload = $encrypted_data . '::' . $iv;
$hmac = hash_hmac( 'sha256', $payload, $mac_key, true );
return base64_encode( $payload . $hmac );
}