如何在我的密码中使用salt设置Apache HTTP授权?

我使用Apache 2和MySQL 5 mod_auth_mysql进行Apache授权。 现在我们的密码被存储在我们的数据库中。 作为一个新的要求,我们必须用盐把它们储存起来,来对抗彩虹表攻击。 该文件指出:

 AuthMySQLSaltField <> | <string> | mysql_column_name Contains information on the salt field to be used for crypt and aes encryption methods. It can contain one of the following: <>: password itself is the salt field (use with crypt() only) <string>: "string" as the salt field mysql_column_name: the salt is take from the mysql_column_name field in the same row as the password This field is required for aes encryption, optional for crypt encryption. It is ignored for all other encryption types. 

所以它看起来像模块可以做到这一点,但我不能find任何关于如何做到这一点? 我应该把什么密码列? 我应该把盐放在什么地方? 我如何使用AES? (大多数应用程序将用于创build用户的PHP

这取决于你的盐是什么!

一般来说,你可以使用一些用户不能改变的东西,比如它们的ID,作为盐; 如果是这种情况,请指定包含用户标识的列。

如果您使用的是恒盐,请将其放入<>标记中。

盐应该是一个随机的string,不是md5 / sha1 / 256。 你提出的文件是寻找盐在它自己的专栏。 所以你“需要”3授权使用的列

 Usersname/email = user submitted passwordhash = hash(password, passwordsalt) passwordsalt = random string 

您可以轻松使用这些列来validation密码,并使用salt和hash创build新的用户logging。

永远不要存储纯文本密码。

至于hash()函数,请看一下phpass库。 这是什么时候,他们最终在数据库中腌制过的哈希值的转向。