3

Possible Duplicate:
What is the optimal length for user password salt?

I have a database like below:

create table user (id int primary key auto increment,
     username varchar(64),
     password varchar(128), # sha512 hash of password
     password_salt varchar(128) # sha512 hash of a random number used as salt
)

Is this a good idea for ensuring password security with a salt? How long should a salt be? I assume that it can't hurt to have a 128bit (SHA-512) salt, but I've been wrong before.

4

1 回答 1

1

我有几点意见:

  • 每个用户的盐应该是随机且唯一的,但它们不必是哈希摘要。盐的想法只是使每个用户的哈希摘要唯一,以抵抗字典攻击和彩虹表攻击。无论盐的长度如何,盐都不会增加哈希摘要算法的强度。

  • DES 使用 12 位作为盐。更新的 UNIX 密码系统使用更多,最多 128 位。

  • 如果您想要更强的密码,请考虑使用bcryptPBKDF2

  • FWIW,一个 SHA-512 哈希摘要(编码为十六进制数字)总是正好 128 个字符,无论输入的长度如何。所以我会使用 CHAR(128) 而不是 VARCHAR(128)。使用 BINARY(2) 或 BINARY(3) 作为盐。

于 2011-09-15T22:55:12.600 回答