gpt4 book ai didi

php - 如何在 php 中解密散列密码?使用 password_hash() 方法散列的密码

转载 作者:行者123 更新时间:2023-12-05 09:15:37 26 4
gpt4 key购买 nike

我想解密通过php的password_hash()方法加密后的加密密码

<?php

$password = 12345;
$hashed_password = password_hash($password, PASSWORD_DEFAULT);

?>

在上面的代码中,我想将 $hashed_pa​​ssword 解密为 12345。我该怎么做。

最佳答案

你不需要

The used algorithm, cost and salt are returned as part of the hash. Therefore, all information that's needed to verify the hash is included in it. This allows the password_verify() function to verify the hash without needing separate storage for the salt or algorithm information.

    $passwordEnteredFirstTime = '12345';
$passwordEnteredSecondTime = '12345';

$passwordHash = password_hash($passwordEnteredFirstTime, PASSWORD_BCRYPT);
$passIsValid = password_verify($passwordEnteredSecondTime, $passwordHash);
echo $passIsValid ? 'correct password' : 'wrong password';

关于php - 如何在 php 中解密散列密码?使用 password_hash() 方法散列的密码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52273284/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com