当前位置:网站首页>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反序列化漏洞
- (4) Function, Bug, Class and Object, Encapsulation, Inheritance, Polymorphism, Copy
- Phonebook
- 17. JS conditional statements and loops, and data type conversion
- PHP实现搜索框的自动反查提示
- 英语每日打卡
- hackmyvm-hopper预排
- The roll call system and array elements find maximum and minimum values for sorting of objects
- GreenOptic: 1 vulnhub walkthrough
- (1) introduction to Thinkphp6, installation view, template rendering, variable assignment
猜你喜欢
随机推荐
The learning path of a network security mouse - the basic use of nmap
ES6 iterator explanation example
hackmyvm-bunny预排
After Alibaba Cloud sets up domain name resolution redirection, I cannot use Chrome to access it
hackmyvm-hopper预排
Phonebook
How to log in to Alibaba Cloud server using the admin account
文件上传漏洞
MOMENTUM: 2 vulnhub walkthrough
Praying: 1 vulnhub walkthrough
英语每日打卡
Laravel随笔记录
[Hello World教程] 使用HBuilder和Uni-app 生成一个简单的微信小程序DEMO
借贷记账法下的账户结构、借贷记账法的记账规则、借贷记账法下的账户对应关系与会计分录
英语每日打卡
(7) superficial "crawlers" process (concept + practice)
Smart Tips for Frida Scripting in Kali Environment
[campo/random-user-agent] Randomly fake your User-Agent
How to calculate the distance between two points on the earth (with formula derivation)
A network security guinea pig's learning path - scripting of advanced usage of nmap








