W3cubDocs

/Phalcon 2

Class Phalcon\Crypt

implements Phalcon\CryptInterface

Provides encryption facilities to phalcon applications

$crypt = new Phalcon\Crypt();

$key = 'le password';
$text = 'This is a secret text';

$encrypted = $crypt->encrypt($text, $key);

echo $crypt->decrypt($encrypted, $key);

Constants

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

Methods

public Phalcon\Encrypt setCipher (string $cipher)

Sets the cipher algorithm

public string getCipher ()

Returns the current cipher

public Phalcon\Encrypt setMode (unknown $mode)

Sets the encrypt/decrypt mode

public string getMode ()

Returns the current encryption mode

public Phalcon\Encrypt setKey (string $key)

Sets the encryption key

public string getKey ()

Returns the encryption key

public Phalcon\CryptInterface setPadding (unknown $scheme)

public int getPadding ()

Returns the padding scheme

public string encrypt (string $text, [string $key])

Encrypts a text

$encrypted = $crypt->encrypt("Ultra-secret text", "encrypt password");

public string decrypt (string $text, [string $key])

Decrypts an encrypted text

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 getAvailableCiphers ()

Returns a list of available cyphers

public array getAvailableModes ()

Returns a list of available modes

© 2011–2016 Phalcon Framework Team
Licensed under the Creative Commons Attribution License 3.0.
https://docs.phalconphp.com/en/2.0.0/api/Phalcon_Crypt.html