Encrypt Decrypt string using cakephp

Encrypt Decrypt string using cakephp’s inbuilt function.

Remember one thing, to archive this you have to use Security Component before using it.

 * Encrypt a String using inbuilt cakephp function
$secret = Security::cipher('StringToEncrypt', 'yourEncryptionKey');
 * Encrypt a string Example
$encryptKey = 'ab12333way2code';
$secret = Security::cipher('i want security', $encryptKey);
 * Decrypt a String
$nosecret = Security::cipher($secret, $encryptKey);

This way you can encrypt/decrypt string using cakephp.

For betterment of usage you can use base64 encoding and decoding system to add an extra advantage to it.

 * Encrypt and base64 encode 
$secret = Security::cipher('hello world', $encryptKey);
$secret64Enc = base64_encode($secret);
// Decrypt your text
$secret64Dec = base64_decode($secret64Enc);
$nosecret = Security::cipher($secret64Dec,$encryptKey);
echo $nosecret ;

Keep Coding