implements Phalcon\CryptInterface
Provides encryption facilities to phalcon applications
<?php
$crypt = new Phalcon\Crypt();
$key = 'le password';
$text = 'This is a secret text';
$encrypted = $crypt->encrypt($text, $key);
echo $crypt->decrypt($encrypted, $key);
integer PADDING_DEFAULT
integer PADDING_ANSI_X_923
integer PADDING_PKCS7
integer PADDING_ISO_10126
integer PADDING_ISO_IEC_7816_4
integer PADDING_ZERO
integer PADDING_SPACE
public Phalcon\Encrypt setMethod (string $method)
Sets the cipher method
public string getMethod ()
Returns the current cipher method
public Phalcon\Encrypt setKey (string $key)
Sets the encryption key
public string getKey ()
Returns the encryption key
public Phalcon\CryptInterface setOptions (int $options)
Sets the options
public int getOptions ()
Returns the options
public Phalcon\CryptInterface setPadding (int $padding)
Sets the padding
public int getPadding ()
Returns the padding
public string encrypt (string $text, [string $key], [unknown $options])
Encrypts a text
<?php
$encrypted = $crypt->encrypt("Ultra-secret text", "encrypt password");
public string decrypt (string $text, [string $key], [int $options])
Decrypts an encrypted text
<?php
echo $crypt->decrypt($encrypted, "decrypt password");
public string encryptBase64 (string $text, [string $key], [unknown $safe])
Encrypts a text returning the result as a base64 string
public string decryptBase64 (string $text, [string $key], [unknown $safe])
Decrypt a text that is coded as a base64 string
public array getAvailableMethods ()
Returns a list of available modes
public beforeEncrypt (callable $handler)
Adds a internal hooks before encrypts a text
public afterEncrypt (callable $handler)
Adds a internal hooks after encrypts a text
public beforeDecrypt (callable $handler)
Adds a internal hooks before decrypts an encrypted text
public afterDecrypt (callable $handler)
Adds a internal hooks after decrypts an encrypted text