acf_encrypt()
acf_encrypt
This function will encrypt a string using PHP https://bhoover.com/using-php-openssl_encrypt-openssl_decrypt-encrypt-decrypt-data/
Хуков нет.
Возвращает
(Строку).
Использование
acf_encrypt( $data );
- $data
- .
По умолчанию: ''
Список изменений
| С версии 5.5.8 | Введена. |
Код acf_encrypt() acf encrypt ACF 6.4.2
function acf_encrypt( $data = '' ) {
// bail early if no encrypt function
if ( ! function_exists( 'openssl_encrypt' ) ) {
return base64_encode( $data );
}
// generate a key
$key = wp_hash( 'acf_encrypt' );
// Generate an initialization vector
$iv = openssl_random_pseudo_bytes( openssl_cipher_iv_length( 'aes-256-cbc' ) );
// Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector.
$encrypted_data = openssl_encrypt( $data, 'aes-256-cbc', $key, 0, $iv );
// The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::)
return base64_encode( $encrypted_data . '::' . $iv );
}