10

パスワードに対して、ユーザーごとおよびサイト全体のソルトを正しく実行しようとしています。これが私が持っているものです:

require('../../salt.php'); //this is above the web root and provides $salt variable
$pw = mysql_real_escape_string($_POST['pw']);
$per_user_salt = uniqid(mt_rand());
$site_salt = $salt //from salt.php that was required on first line
$combine = $pw . $per_user_salt . $site_salt;
$pw_to_put_in_db = hash("sha512", $combine);

これは正しいですか?ありがとう

4

4 に答える 4

0

crypt を使用してください。すべての言語で利用でき、パスワード ハッシュは他のプログラムでも使用できます。

$hash = crypt("secret", "$6$randomsalt$");
于 2013-06-13T18:12:34.087 に答える
0

多くの場合、パスワードに連結された一意のソルトを使用し、次に hmac メソッドを使用してサイト全体のハッシュ キーを追加します。

http://www.php.net/manual/en/function.hash-hmac.php

$password = hash_hmac('sha512', $password . $salt, $sitewide_key);
于 2011-06-25T18:17:35.610 に答える
0

これは、 「sha512」から「 を削除しただけで問題ありません:)

$pw = $_POST['pw'];
$per_user_salt = uniqid(mt_rand());
$site_salt = $salt //from salt.php that was required on first line
$combine = $pw . $per_user_salt . $site_salt;
$pw_to_put_in_db = hash(sha512, $combine);

md5を使用する必要はありませんsha512はそれ自体で十分に安全です

于 2013-06-08T10:56:50.447 に答える