我在PHP.net上读到MD5没用,他们建议使用crypt + salt。
因此,我转到他们的函数描述,并阅读
<?php
$password = crypt('mypassword'); // let the salt be automatically generated
/* You should pass the entire results of crypt() as the salt for comparing a
password, to avoid problems when different hashing algorithms are used
正如在这个美妙的链接中所提到的,获得给定密码的用户的PBKDF2哈希的方法
密码(当然),
一种盐(产生密码安全的随机数发生器。
迭代计数(选择的高度足够安全,同时平衡应用程序的可用性容忍度)
散列大小(要计算的哈希长度)
/** * Computes the PBKDF2 hash of a password. * * @param password the password to hash. * @param salt the salt * @param iterations the iteration
我不理解的文档。在测试原始加密时,他们似乎使用了密码的加密版本作为盐。
当我不带可选的第二个参数(the salt)插入crypt时,我得到了相同密码的不同加密版本。这是预期的行为吗?
但是,如果我插入第二个参数'd4‘,那么对于相同的密码输入,我会得到相同的加密密码。预期行为。
在注册时插入之前:
$pass = crypt('$pass', 'd4'); // after this I insert $pass into the mysql table
登录测试:
$pass = crypt($pass, 'd4'); // afte
我有一个MySQL 'users‘表,其中包含以下列: uname、hash、salt和pwd。我正在测试一个PHP登录页面,它使用这个表来获得用户访问权限。我目前还没有系统设置来注册用户,所以测试通过手动添加数据到表中,具有以下.....
uname: 'testuser',
pwd: 'password'
用来检查密码的php函数如下:
function checkPwd($uname, $pwd){
// Get the hash and salt for this user:
$q = "SELECT hash, salt
我一直在查看和Stackoverflow上的几个,我正在试图找出咸的和散列的密码。
我在PHP社区页面上找到了这个:
<?php
function md5crypt($password){
// create a salt that ensures crypt creates an md5 hash
$base64_alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
.'abcdefghijklmnopqrstuvwxyz0123456789+/';
$salt=