phalcon: crypt-encrypt/decrypt用法
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了phalcon: crypt-encrypt/decrypt用法相关的知识,希望对你有一定的参考价值。
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用法的主要内容,如果未能解决你的问题,请参考以下文章
text phalcon-devtools #Phalcon
Phalcon 开发工具(Phalcon Developer Tools)
mac环境下安装phalcon并将扩展phalcon.so添加到php.ini后,浏览器打开phpinfo怎么没有显示phalcon扩展?