当前位置:网站首页>PHP hash加密与解密
PHP hash加密与解密
2022-08-02 03:26:00 【陌潇】
几年前用的 md5 和加盐的加密方式都比较容易破解。今天做用户登录注册的时候遇到了hash加密的问题,顺便记录一下。
第一、加密
用到 password_hash() 函数:简单使用
//PASSWORD_DEFAULT 加密算法,目前是60位字符,官网说php的更新可能会变化的更长,多以存储的时候最好255
//123456 为需要加密的字符串
password_hash('123456',PASSWORD_DEFAULT);
第二、解密
加密倒是挺简单的,想要取出来用的时候发现没有解密的方法,找了半天也没有找到,应该是没有解密的办法,说是有个一对比的方法:password_verify()
//123456为用户输入的明文密码
//$password 这个则为加密后的60位
$password = '$2y$10$GDoAkNDzomsI5sbx.UpVh.FOMTwJqahuVNd9RcmMbCtLfPe3vr3kW';
password_verify('123456',$password );
这个方法返回 true 或 false ,不用说了吧。都应该能懂!!!
边栏推荐
- 不懂“赚钱逻辑”,你永远都是社会最底层(广告电商)
- 命令执行漏洞
- PHP Foundation March Press Announcement Released
- 云安全笔记:云原生全链路加密
- The first time to tear the code by hand, how to solve the problem of full arrangement
- CTF入门之md5
- Laravel随笔记录
- Masashi: 1 vulnhub walkthrough
- 链动2+1模式开发系统
- [sebastian/diff] A historical change extension library for comparing two texts
猜你喜欢
随机推荐
WeChat applet development video loading: [Rendering layer network layer error] Failed to load media
Alfa: 1 vulnhub walkthrough
hackmyvm: juggling walkthrough
Eric target penetration test complete tutorial
uniapp | Problems with the use of the official map component
CTF entry md5
ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
Eric靶机渗透测试通关全教程
Kali环境下Frida编写脚本智能提示
链动2+1模式开发系统
hackmyvm: controller walkthrough
17. JS conditional statements and loops, and data type conversion
利用cookie获取admin权限 CTF基础题
最简单的FRP内网穿透教程
hackmyvm-bunny预排
Command Execution Vulnerability
链动2+1无限循环系统,2022年起盘成功率超高的模式
管理会计(对内)指引、管理会计要素及其具体内容(可能考,考前记一下,推荐记一下四个大点即可)、
[sebastian/diff] A historical change extension library for comparing two texts
Warzone: 3 (Exogen) vulnhub walkthrough