PHP 密码哈希和验证

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 密码哈希和验证相关的知识,希望对你有一定的参考价值。

function generate_hash ($plain_text, $salt = null) {
	
	if ($salt === null) {
		$salt = substr(md5(uniqid(rand(), true)), 0, 12);
	} else {
		$salt = substr($salt, 0, 12);
	}

	return $salt . sha1($salt . $plain_text);
	
}

以上是关于PHP 密码哈希和验证的主要内容,如果未能解决你的问题,请参考以下文章