编程语言
首页 > 编程语言> > php – 密码加密方法? :PASSWORD()与md5?

php – 密码加密方法? :PASSWORD()与md5?

作者:互联网

只是想知道密码加密的方法是否有利有弊…通常,我会使用php并使用md5加密密码,然后再将新用户插入数据库.我最近继承了一个项目,他们在sql插入查询中使用PASSWORD()来加密它.那么,现在我想知道使用一个优于另一个是否有优势?

解决方法:

the MySQL docs for PASSWORD

The PASSWORD() function is used by the authentication system in
MySQL Server; you should not use it in your own applications. For
that purpose, consider MD5() or SHA2() instead. Also see RFC 2195,
section 2 (Challenge-Response Authentication Mechanism (CRAM)), for
more information about handling passwords and authentication securely
in your applications.

在该注释下面是不依赖该功能的一个很好的理由:

Statements that invoke PASSWORD() may be recorded in server
logs or in a history file such as ~/.mysql_history, which means that
plaintext passwords may be read by anyone having read access to that
information.

密码通常最好与盐渍哈希(SHA等)一起存储.这是an answer,其中列出了一些有关安全密码存储的有用链接.

标签:php,mysql,password-encryption
来源: https://codeday.me/bug/20190721/1494943.html