Crypt

Configuration & usage

Phalcon provides encryption facilities via the Phalcon\Crypt component. This class offers simple object-oriented wrappers to the openssl PHP’s encryption library.

By default, this component utilizes the AES-256-CFB cipher.

The cipher AES-256 is used among other places in SSL/TLS across the Internet. It’s considered among the top ciphers. In theory it’s not crackable since the combinations of keys are massive. Although NSA has categorized this in Suite B, they have also recommended using higher than 128-bit keys for encryption.

Configurations

Crypt Settings

Define which cipher and hashing algorithm you want to use. You can choose between

# Crypt Settings
CRYPT_CIPHER=aes-256-cfb
CRYPT_HASH=sha256
CRYPT_USE_SIGNING=false

Usage

// if the class is aware of injections
$crypt = $this->crypt;

// if the container is present
$crypt = $this->di->get('crypt');

// to access the shared db service
$crypt = Di::getDefault()->get('crypt');

Sources

Last updated