我使用这个代码加密我的数据到blwofish,但我不知道真的转换为河豚或其他加密。
echo crypt('ab','$2a$09$anexamplestringforsalt$')."\n
";和我正在尝试底层代码,但它是假的echo CRYPT_BLOWFISH('ab','$2a$09$anexamplestringforsalt$')."\n
";
发布于 2014-03-19 22:42:30
它是crypt参数字符串,用于定义所使用的算法:
$2a : This describes the algorithm (BCrypt) but should be 2y nowadays
$09 : This is the number of rounds and is usually 10 or higher
$anexamplestringforsalt : This should be a really random salt of a given alphabet要生成PHP哈希,使用新的password_hash()函数要安全得多,不过,对于早期的BCrypt版本也有一个compatibility pack。
// Hash a new password for storing in the database.
// The function automatically generates a cryptographically safe salt.
$hashToStoreInDb = password_hash($password, PASSWORD_BCRYPT);
// Check if the hash of the entered login password, matches the stored hash.
// The salt and the cost factor will be extracted from $existingHashFromDb.
$isPasswordCorrect = password_verify($password, $existingHashFromDb);https://stackoverflow.com/questions/22474588
复制相似问题