class CRM_Utils_Crypt

Methods

static string
encrypt(string $string)

Encrypts a string using AES256 in ECB mode, if encryption is enabled.

static string
decrypt(string $string)

Decrypts ciphertext encrypted with AES256 in ECB mode, if possible.

Details

at line 50
static string encrypt(string $string)

Encrypts a string using AES256 in ECB mode, if encryption is enabled.

After encrypting the string, it is base64 encoded.

If encryption is not enabled, either due to CIVICRM_SITE_KEY being undefined or due to unavailability of the mcrypt module, the string is merely base64 encoded and is not encrypted at all.

Parameters

string $string Plaintext to be encrypted.

Return Value

string Base64-encoded ciphertext, or base64-encoded plaintext if encryption is disabled or unavailable.

at line 84
static string decrypt(string $string)

Decrypts ciphertext encrypted with AES256 in ECB mode, if possible.

If the mcrypt module is not available or if CIVICRM_SITE_KEY is not set, the provided ciphertext is only base64-decoded, not decrypted.

Parameters

string $string Ciphertext to be decrypted.

Return Value

string Plaintext, or base64-decoded ciphertext if encryption is disabled or unavailable.