相册的密码安全性

时间:2011-01-23 14:46:33

标签: php security passwords

我正在制作相册系统,您可以选择激活密码保护,这样您就可以为相册制作自己的密码。如果我使用md5,最适合用来存储它的密码是什么? / sha1加密,或者直接将它存储在数据库中,如“123”..?

2 个答案:

答案 0 :(得分:3)

始终以加密形式存储密码,并在加密前附加盐......

The Secure Way to Store Passwords with PHP:

$password = 'ilovjenny84';
$salt = 'SHAKY SHARKY 333'; // some random string
$password_hash = sha1($salt.sha1($password.$salt)); // $password_hash = 4c3c8cbb4aa5de1c3ad9521501c6529506c6e5b4

还请看这篇文章:

PHP encryption for the common man

答案 1 :(得分:0)

不要将它存储为明文,这是不行的。使用SHA系列的功能(如SHA1)。 另外,在密码中使用salt。