PHP Class Contao\Encryption

The class can be used to encrypt and decrypt data based on the encryption string that is set during the Contao installation. Usage: $encrypted = Encryption::encrypt('Leo Feyer'); $decrypted = Encryption::decrypt($encrypted);
Datei anzeigen Open project: contao/core-bundle Class Usage Examples

Protected Properties

Property Type Description
$objInstance Encryption Object instance (Singleton)
$resTd resource Mcrypt resource

Public Methods

Method Description
__clone ( ) Prevent cloning of the object (Singleton)
decrypt ( mixed $varValue, string $strKey = null ) : string Decrypt a value
encrypt ( mixed $varValue, string $strKey = null ) : string Encrypt a value
getInstance ( ) : Encryption Return the object instance (Singleton)
hash ( string $strPassword ) : string Generate a password hash
test ( string $strHash ) : boolean Test whether a password hash has been generated with crypt()
verify ( string $strPassword, string $strHash ) : boolean Verify a readable password against a password hash

Protected Methods

Method Description
__construct ( ) Initialize the encryption module
initialize ( ) Initialize the encryption module

Method Details

__clone() final public method

Prevent cloning of the object (Singleton)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Encryption class is now static.
final public __clone ( )

__construct() protected method

Initialize the encryption module
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Encryption class is now static.
protected __construct ( )

decrypt() public static method

Decrypt a value
public static decrypt ( mixed $varValue, string $strKey = null ) : string
$varValue mixed The value to decrypt
$strKey string An optional encryption key
return string The decrypted value

encrypt() public static method

Encrypt a value
public static encrypt ( mixed $varValue, string $strKey = null ) : string
$varValue mixed The value to encrypt
$strKey string An optional encryption key
return string The encrypted value

getInstance() public static method

Return the object instance (Singleton)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. The Encryption class is now static.
public static getInstance ( ) : Encryption
return Encryption

hash() public static method

Generate a password hash
public static hash ( string $strPassword ) : string
$strPassword string The unencrypted password
return string The encrypted password

initialize() protected static method

Initialize the encryption module
protected static initialize ( )

test() public static method

Test whether a password hash has been generated with crypt()
public static test ( string $strHash ) : boolean
$strHash string The password hash
return boolean True if the password hash has been generated with crypt()

verify() public static method

Verify a readable password against a password hash
See also: https://github.com/ircmaxell/password_compat
public static verify ( string $strPassword, string $strHash ) : boolean
$strPassword string The readable password
$strHash string The password hash
return boolean True if the password could be verified

Property Details

$objInstance protected_oe static_oe property

Object instance (Singleton)
protected static Encryption,contao $objInstance
return Encryption

$resTd protected_oe static_oe property

Mcrypt resource
protected static resource $resTd
return resource