本文实例讲述了YII2框架可逆加密简单实现方法。分享给大家供大家参考,具体如下:
[b]加密:[/b]
$data 是你要加密的内容
$secretKey 是你自己设置的salt
$encryptedData = Yii::$app->getSecurity()->encryptByPassword($data, $secretKey);
[b]解密:[/b]
$encryptedData 是你要解密的内容
$secretKey 是你自己设置加密时的salt
$data = Yii::$app->getSecurity()->decryptByPassword($encryptedData, $secretKey);
[b]PS:关于加密解密感兴趣的朋友还可以参考本站在线工具:[/b]
[b]文字在线加密解密工具(包含AES、DES、RC4等):
[/b][url=http://tools.jb51.net/password/txt_encode]http://tools.jb51.net/password/txt_encode[/url]
[b]MD5在线加密工具:
[/b][url=http://tools.jb51.net/password/CreateMD5Password]http://tools.jb51.net/password/CreateMD5Password[/url]
[b]在线散列/哈希算法加密工具:
[/b][url=http://tools.jb51.net/password/hash_encrypt]http://tools.jb51.net/password/hash_encrypt[/url]
[b]在线MD5/hash/SHA-1/SHA-2/SHA-256/SHA-512/SHA-3/RIPEMD-160加密工具:
[/b][url=http://tools.jb51.net/password/hash_md5_sha]http://tools.jb51.net/password/hash_md5_sha[/url]
[b]在线sha1/sha224/sha256/sha384/sha512加密工具:
[/b][url=http://tools.jb51.net/password/sha_encode]http://tools.jb51.net/password/sha_encode[/url]
更多关于Yii相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/386.htm]Yii框架入门及常用技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/155.htm]php优秀开发框架总结[/url]》、《[url=http://www.1sucai.cn/Special/26.htm]smarty模板入门基础教程[/url]》、《[url=http://www.1sucai.cn/Special/43.htm]php面向对象程序设计入门教程[/url]》、《[url=http://www.1sucai.cn/Special/47.htm]php字符串(string)用法总结[/url]》、《[url=http://www.1sucai.cn/Special/84.htm]php+mysql数据库操作入门教程[/url]》及《[url=http://www.1sucai.cn/Special/231.htm]php常见数据库操作技巧汇总[/url]》
希望本文所述对大家基于Yii框架的PHP程序设计有所帮助。