$crypt = new \Phalcon\Legacy\Crypt();
$key = 'le password';
$text = 'This is a secret text';
$encrypted = $crypt->encrypt($text, $key);
echo $crypt->decrypt($encrypted, $key);
Show file
Open project: phalcon/incubator
Class Usage Examples
Property | Type | Description | |
---|---|---|---|
$cipher | |||
$key | |||
$mode | |||
$padding |
Method | Description | |
---|---|---|
decrypt ( string $text, string $key = null ) : string | Decrypts a text | |
decryptBase64 ( string $text, mixed $key = null, boolean $safe = false ) : string | Decrypt a text that is coded as a base64 string | |
encrypt ( string $text, mixed $key = null ) : string | Encrypts a text | |
encryptBase64 ( string $text, mixed $key = null, boolean $safe = false ) : string | Encrypts a text returning the result as a base64 string | |
getAvailableCiphers ( ) : array | Returns a list of available cyphers | |
getAvailableModes ( ) : array | Returns a list of available modes | |
getCipher ( ) : string | Returns the current cipher | |
getKey ( ) : string | Returns the encryption key | |
getMode ( ) : string | Returns the current encryption mode | |
setCipher ( string $cipher ) : Phalcon\Legacy\CryptInterface | ||
setKey ( string $key ) : Phalcon\Legacy\CryptInterface | Sets the encryption key | |
setMode ( string $mode ) : Phalcon\Legacy\CryptInterface | Sets the encrypt/decrypt mode | |
setPadding ( integer $scheme ) : Phalcon\Legacy\CryptInterface | Changes the padding scheme used |
Method | Description | |
---|---|---|
cryptPadText ( string $text, string $mode, integer $blockSize, integer $paddingType ) : string | Pads texts before encryption | |
cryptUnpadText ( string $text, string $mode, integer $blockSize, integer $paddingType ) : string | Removes $paddingType padding from text If the function detects that the text was not padded, it will return it unmodified |
protected cryptUnpadText ( string $text, string $mode, integer $blockSize, integer $paddingType ) : string | ||
$text | string | Message to be unpadded |
$mode | string | Encryption mode; unpadding is applied only in CBC or ECB mode |
$blockSize | integer | Cipher block size |
$paddingType | integer | Padding scheme |
return | string |
echo $crypt->decrypt($encrypted, "decrypt password");
$encrypted = $crypt->encrypt("Ultra-secret text", "encrypt password");
public getAvailableCiphers ( ) : array | ||
return | array |
public getAvailableModes ( ) : array | ||
return | array |
public setPadding ( integer $scheme ) : Phalcon\Legacy\CryptInterface | ||
$scheme | integer | |
return | Phalcon\Legacy\CryptInterface |