简体   繁体   English

PHP:MD5哈希输入字符串的长度是否有任何实际限制?

[英]PHP: Is there any practical limit to the length of the input string for MD5 hashing?

I'm storing some passwords in a database using PHP+MySQL 我正在使用PHP + MySQL将一些密码存储在数据库中

I realise that MD5 is not a secure method to store passwords, but for now I'm using it mainly to ensure that regardless of the length of the password, it can be stored in the database easily. 我意识到MD5不是一种存储密码的安全方法,但是现在我主要用它来确保无论密码的长度如何,它都可以轻松地存储在数据库中。

For that I'm hashing the password using PHP and storing it in the database. 为此,我使用PHP散列密码并将其存储在数据库中。

Is there any practical limit on the length of a password I can store using this manner? 我可以用这种方式存储的密码长度是否有任何实际限制?

(security is not of importance here, I am using the hashing only for convenience) (安全性在这里并不重要,我只是为了方便而使用散列)

No, you do not have to limit the length. 不,你不必限制长度。 PHP already contains some safety checks on the maximum request size to avoid malicious users from filling up your memory. PHP已经包含对最大请求大小的一些安全检查,以避免恶意用户填满您的内存。

But as you mentioned: MD5 is NOT ACCEPTABLE to hash passwords. 但正如您所提到的:MD5不可接受哈希密码。 Neither is any other hashing algorithm unless you use it with a salt ! 除非你在盐中使用它,否则也没有任何其他哈希算法!

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

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