简体   繁体   English

PHP 5.3.3的密码保护?

[英]Password protection for php 5.3.3?

I'm doing an assignment for uni and I've been following guides as far as finding a way to hash a registered password onto the mysqli database but it seem's the university's myphp is only on 5.3.3 and MySQL 5.1.73. 我正在为uni分配作业,我一直在遵循指南,以寻找一种将注册的密码散列到mysqli数据库上的方法,但是看来大学的myphp仅在5.3.3和MySQL 5.1.73上。

What can I use to hash it instead of using 5.5's password_hash() function? 我可以使用什么对其进行哈希处理,而不是使用5.5的password_hash()函数? Don't suppose there's a handy tutorial out there for it? 不要以为有方便的教程吗?

Many thanks! 非常感谢!

Your best answer: 您最好的答案:

Have them upgrade to PHP 5.5 or higher and use password_hash() with a high work factor. 让他们升级到PHP 5.5或更高版本,并以较高的工作效率使用password_hash()

Point them to Thomas Pornin's canonical Security.stackexchange answer to How to securely hash passwords? 将他们指向托马斯·珀金(Thomas Pornin)关于如何安全地散列密码的规范Security.stackexchange答案。 to let him help argue the case for good password security. 让他帮助为良好的密码安全性辩护。

Your next best answer: 您的下一个最佳答案:

Have them upgrade to PHP 5.3.7 or higher and use the password_hash() compatibility pack 让他们升级到PHP 5.3.7或更高版本,并使用password_hash()兼容性包

See above. 往上看。

Your not as good answer: 您的回答不太好:

You can use crypt on your current PHP 5.3.3 version reasonably IF you change some of the options: 如果更改某些选项,则可以在当前的PHP 5.3.3版本上合理使用crypt

crypt('password', '$6$rounds=150000$PerUserCryptoRandomSalt$')
  • $6 - use SHA-512, which has 64-bit operations that reduce the margin of advantage most GPU based attackers have over you as of early 2016. $ 6-使用SHA-512,它具有64位操作,从而降低了截至2016年初大多数基于GPU的攻击者对您的优势。

  • $rounds=150000 - set the number of iterations to hundreds of thousands or high tens of thousands of rounds. $ rounds = 150000-将迭代次数设置为成千上万次或上万次。

  • PerUserCryptoRandomSalt - unlike password_hash, you have to do this yourself. PerUserCryptoRandomSalt-与password_hash不同,您必须自己执行此操作。 You need to generate a unique, cryptographically random salt of 12-24 binary bytes (16 is very reasonable) 您需要生成12-24个二进制字节的唯一的,随机加密的盐(16个非常合理)

    • Note that it's part of the result string, in cleartext, which is correct. 请注意,它是结果字符串的一部分,以明文形式显示,这是正确的。

    • That's binary bytes! 那是二进制字节! The size in the crypt() function gets doubled if you convert to hex, or increased by 4/3rds if you Base64 it 如果转换为十六进制,crypt()函数的大小将增加一倍,如果使用Base64,则将大小增加4 / 3rds

To compare, you get the user's salt and number of rounds, and use crypt with those on the candidate password entered. 为了进行比较,您需要得到用户的盐和回合数,并使用crypt和输入的候选密码中的密码进行加密。 If you get the same answer, it's the same password. 如果您得到相同的答案,那就是相同的密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM