PHP 클래스 lithium\storage\session\strategy\Encrypt

To use this class, you need to have the mcrypt extension enabled. Example configuration: {{{ Session::config(array('default' => array( 'adapter' => 'Cookie', 'strategies' => array('Encrypt' => array('secret' => 'foobar')) ))); }}} By default, this strategy uses the AES algorithm in the CBC mode. This means that an initialization vector has to be generated and transported with the payload data. This is done transparently, but you may want to keep this in mind (the ECB mode doesn't require an itialization vector but is not recommended to use as it's insecure). You can override this defaults by passing a different cipher and/or mode to the config like this: {{{ Session::config(array('default' => array( 'adapter' => 'Cookie', 'strategies' => array('Encrypt' => array( 'cipher' => MCRYPT_RIJNDAEL_128, 'mode' => MCRYPT_MODE_ECB, // Don't use ECB when you don't have to! 'secret' => 'foobar' )) ))); }}} Please keep in mind that it is generally not a good idea to store sensitive information in cookies (or generally on the client side) and this class is no exception to the rule. It allows you to store client side data in a more secure way, but 100% security can't be achieved.
상속: extends lithium\core\Object
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_defaults Default configuration.
$_resource Holds the crypto resource after initialization.
$_vector Holds the initialization vector.

공개 메소드들

메소드 설명
__construct ( array $config = [] ) : void Constructor.
__destruct ( ) : void Destructor. Closes the crypto resource when it is no longer needed.
delete ( mixed $data, array $options = [] ) : string Delete encryption method.
enabled ( ) : boolean Determines if the Mcrypt extension has been installed.
read ( array $data, array $options = [] ) : mixed Read encryption method.
write ( mixed $data, array $options = [] ) : string Write encryption method.

보호된 메소드들

메소드 설명
_decrypt ( string $encrypted ) : array Decrypt and unserialize a previously encrypted string.
_encrypt ( array $decrypted = [] ) : string Serialize and encrypt a given data array.
_hashSecret ( string $key ) : string Hashes the given secret to make harder to detect.
_vector ( ) : string Generates an initialization vector.
_vectorSize ( ) : number Returns the vector size vor a given cipher and mode.

메소드 상세

__construct() 공개 메소드

Constructor.
public __construct ( array $config = [] ) : void
$config array Configuration array. You can override the default cipher and mode.
리턴 void

__destruct() 공개 메소드

Destructor. Closes the crypto resource when it is no longer needed.
public __destruct ( ) : void
리턴 void

_decrypt() 보호된 메소드

Decrypt and unserialize a previously encrypted string.
protected _decrypt ( string $encrypted ) : array
$encrypted string The base64 encoded and encrypted string.
리턴 array The cleartext data.

_encrypt() 보호된 메소드

Serialize and encrypt a given data array.
protected _encrypt ( array $decrypted = [] ) : string
$decrypted array The cleartext data to be encrypted.
리턴 string A Base64 encoded and encrypted string.

_hashSecret() 보호된 메소드

This method figures out the appropriate key size for the chosen encryption algorithm and then hashes the given key accordingly. Note that if the key has already the needed length, it is considered to be hashed (secure) already and is therefore not hashed again. This lets you change the hashing method in your own code if you like. The default MCRYPT_RIJNDAEL_128 key should be 32 byte long sha256 is used as the hashing algorithm. If the key size is shorter than the one generated by sha256, the first n bytes will be used.
protected _hashSecret ( string $key ) : string
$key string The possibly too weak key.
리턴 string The hashed (raw) key.

_vector() 보호된 정적인 메소드

Generates an initialization vector.
protected static _vector ( ) : string
리턴 string Returns an initialization vector.

_vectorSize() 보호된 정적인 메소드

Returns the vector size vor a given cipher and mode.
protected static _vectorSize ( ) : number
리턴 number The vector size.

delete() 공개 메소드

Delete encryption method.
public delete ( mixed $data, array $options = [] ) : string
$data mixed The data to be encrypted.
$options array Options for this method.
리턴 string Returns the deleted data in cleartext.

enabled() 공개 정적인 메소드

Determines if the Mcrypt extension has been installed.
public static enabled ( ) : boolean
리턴 boolean `true` if enabled, `false` otherwise.

read() 공개 메소드

Read encryption method.
public read ( array $data, array $options = [] ) : mixed
$data array the Data being read.
$options array Options for this method.
리턴 mixed Returns the decrypted key or the dataset.

write() 공개 메소드

Write encryption method.
public write ( mixed $data, array $options = [] ) : string
$data mixed The data to be encrypted.
$options array Options for this method.
리턴 string Returns the written data in cleartext.

프로퍼티 상세

$_defaults 보호되어 있는 프로퍼티

Default configuration.
protected $_defaults

$_resource 보호되어 있는 정적으로 프로퍼티

Holds the crypto resource after initialization.
protected static $_resource

$_vector 보호되어 있는 정적으로 프로퍼티

Holds the initialization vector.
protected static $_vector