标签:
phalcon:crypt加密与解密
可以在入口文件index.php进行配置,也可以不配置:
$di->set(‘crypt‘, function(){ $crypt = new \Phalcon\Crypt(); return $crypt; }, true); 或者: $di[‘crypt‘] = function(){ $crypt=new \Phalcon\Crypt(); return $crypt; }; 关于调用: $this->crypt; 或者 $this->di[‘crypt‘]; 或者 $this->di->crypt;
加密解密代码:
$key = "le password"; $password = "this is a secret text"; //加密 $crypt = new \Phalcon\Crypt(); $encrypted = $crypt->encrypt($password, $key); echo $encrypted; //解密 $crypt = new \Phalcon\Crypt(); $encrypted = $crypt->encrypt($password, $key); // $password = $crypt->decrypt($encrypted, $key); echo $password;
64位的加密解密方便url传输:
$crypt = new \Phalcon\Crypt(); // $crypt->setCipher(‘blowfish‘); $key = "le password"; $password = "this is a sicret text"; //加密 $encrypted = $crypt->encryptBase64($password, $key); echo $encrypted; echo "<br>"; //解密 $password = $crypt->decryptBase64($encrypted, $key); echo $password;
phalcon: crypt-encrypt/decrypt用法
标签:
原文地址:http://www.cnblogs.com/achengmu/p/5952085.html