encode($value, $key = false)
The encode method encrypts a string value, optionally with a custom encryption key.
Static | No | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
パラメータ |
|
|||||||||
返り値 | string | |||||||||
例 |
|
The Crypt class allows encrypt or decrypt a string. The Crypt class is also used internally by for example the Fuel Sessions class.
It uses the encryption and hashing methods provided by PHPSecLib, so it's not dependent on external modules being available, such as mcrypt.
The Crypt class is configured through the app/config/crypt.php configuration file. It will be generated and populated with random values when you first use the Crypt class or if one of the required configuration values is missing.
Note that this will require write access to app/config/crypt.php! If this is not possible, make sure all configuration settings are set!
The following configuration settings can be defined:
パラメータ | 型 | 規定値 | 説明 |
---|---|---|---|
crypto_key | string | n/a | Random encryption key value used in the encryption routines. Make sure you set this to something unique and random! |
crypto_iv | string | n/a | Random encryption initialisation vector used in the encryption routines. Make sure you set this to something unique and random! |
crypto_hmac | string | n/a | Random value used in the Hash-based Message Authentication Code (HMAC) routines. Make sure you set this to something unique and random! |
If you assign keys manually, note that they are base64_encoded, and the length must be a multiple of 4 to be able to decode it. Make sure the length is correct!
The encode method encrypts a string value, optionally with a custom encryption key.
Static | No | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
パラメータ |
|
|||||||||
返り値 | string | |||||||||
例 |
|
The decode method decrypts a string value, optionally with a custom key.
Static | No | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
パラメータ |
|
|||||||||
返り値 | mixed - String value with the decoded value, or false if the value could not be decoded. | |||||||||
例 |
|