PHP Class Phalcon\Legacy\Crypt

Port of Phalcon 2.0.x Phalcon\Crypt. Provides encryption facilities to phalcon applications. $crypt = new \Phalcon\Legacy\Crypt(); $key = 'le password'; $text = 'This is a secret text'; $encrypted = $crypt->encrypt($text, $key); echo $crypt->decrypt($encrypted, $key);
Inheritance: implements Phalcon\Legacy\CryptInterface
Afficher le fichier Open project: phalcon/incubator Class Usage Examples

Protected Properties

Свойство Type Description
$cipher
$key
$mode
$padding

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode 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

Method Details

cryptPadText() protected méthode

Pads texts before encryption
protected cryptPadText ( string $text, string $mode, integer $blockSize, integer $paddingType ) : string
$text string
$mode string
$blockSize integer
$paddingType integer
Résultat string

cryptUnpadText() protected méthode

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
Résultat string

decrypt() public méthode

echo $crypt->decrypt($encrypted, "decrypt password");
public decrypt ( string $text, string $key = null ) : string
$text string
$key string
Résultat string

decryptBase64() public méthode

Decrypt a text that is coded as a base64 string
public decryptBase64 ( string $text, mixed $key = null, boolean $safe = false ) : string
$text string
$key mixed
$safe boolean
Résultat string

encrypt() public méthode

$encrypted = $crypt->encrypt("Ultra-secret text", "encrypt password");
public encrypt ( string $text, mixed $key = null ) : string
$text string
$key mixed
Résultat string

encryptBase64() public méthode

Encrypts a text returning the result as a base64 string
public encryptBase64 ( string $text, mixed $key = null, boolean $safe = false ) : string
$text string
$key mixed
$safe boolean
Résultat string

getAvailableCiphers() public méthode

Returns a list of available cyphers
public getAvailableCiphers ( ) : array
Résultat array

getAvailableModes() public méthode

Returns a list of available modes
public getAvailableModes ( ) : array
Résultat array

getCipher() public méthode

Returns the current cipher
public getCipher ( ) : string
Résultat string

getKey() public méthode

Returns the encryption key
public getKey ( ) : string
Résultat string

getMode() public méthode

Returns the current encryption mode
public getMode ( ) : string
Résultat string

setCipher() public méthode

public setCipher ( string $cipher ) : Phalcon\Legacy\CryptInterface
$cipher string
Résultat Phalcon\Legacy\CryptInterface

setKey() public méthode

Sets the encryption key
public setKey ( string $key ) : Phalcon\Legacy\CryptInterface
$key string
Résultat Phalcon\Legacy\CryptInterface

setMode() public méthode

Sets the encrypt/decrypt mode
public setMode ( string $mode ) : Phalcon\Legacy\CryptInterface
$mode string
Résultat Phalcon\Legacy\CryptInterface

setPadding() public méthode

Changes the padding scheme used
public setPadding ( integer $scheme ) : Phalcon\Legacy\CryptInterface
$scheme integer
Résultat Phalcon\Legacy\CryptInterface

Property Details

$cipher protected_oe property

protected $cipher

$key protected_oe property

protected $key

$mode protected_oe property

protected $mode

$padding protected_oe property

protected $padding