Function __global->encrypt_data
Definitions
sources/encryption.php
- Encrypt some data using asymmetric encryption and the site's public key. This will return the original data if encryption is disabled. It will add a magic marker to the start of the returned string to show it's been encrypted.A fatal error will occur if the public key cannot be found, or if encryption fails for whatever reason.Note that this will blindly re-encrypt data which has already been encrypted. You should check data with is_data_encrypted() first.
- Visibility: public
- Is abstract?: No
- Is static?: No
- Is final?: No
- Returns: string
Parameters
| Name | Type | Passed by reference? | Variadic? | Default | Set | Range | Description |
|---|---|---|---|---|---|---|---|
| $data | string | No | No | required parameter | N/A | N/A | Data to be encrypted |
| &$error_msg | ?string | Yes | No | Null | N/A | N/A | Error message returned (null: do not return an error message) (blank: fill in error message if there is one) |
Returns
- Encrypted data, with magic marker
- Type: string
- Set: N/A
- Range: N/A
Preview
Code (PHP)
/**
* Encrypt some data using asymmetric encryption and the site's public key. This will return the original data if encryption is disabled. It will add a magic marker to the start of the returned string to show it's been encrypted.A fatal error will occur if the public key cannot be found, or if encryption fails for whatever reason.Note that this will blindly re-encrypt data which has already been encrypted. You should check data with is_data_encrypted() first.
*
* @param string $data Data to be encrypted
* @param ?string $error_msg Error message returned (null: do not return an error message) (blank: fill in error message if there is one)
* @return string Encrypted data, with magic marker
*/
function encrypt_data(string $data, ?string &$error_msg = null) : string
* Encrypt some data using asymmetric encryption and the site's public key. This will return the original data if encryption is disabled. It will add a magic marker to the start of the returned string to show it's been encrypted.A fatal error will occur if the public key cannot be found, or if encryption fails for whatever reason.Note that this will blindly re-encrypt data which has already been encrypted. You should check data with is_data_encrypted() first.
*
* @param string $data Data to be encrypted
* @param ?string $error_msg Error message returned (null: do not return an error message) (blank: fill in error message if there is one)
* @return string Encrypted data, with magic marker
*/
function encrypt_data(string $data, ?string &$error_msg = null) : string

