首页 > 代码库 > phalcon: crypt-encrypt/decrypt用法
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用法
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。