【问题标题】:Secure hash generation for passwords [duplicate]密码的安全哈希生成[重复]
【发布时间】:2013-11-29 20:10:05
【问题描述】:

是否可以通过任何方法从以下函数产生的哈希中获取密码?

$salt 是随机的 128 个字符的字母数字字符串。

function Get_Hash($pwd, $salt)
        {
            if ( CRYPT_BLOWFISH == 1) 
            {
                $pwd = hash("sha512",$pwd);
                $cost = "07";
                $hash = crypt($pwd, '$2a$' . $cost . '$' . $salt);
                return $hash;
            } 
            else  
            {
                $pwd = hash("sha512",$pwd);
                $hash = crypt($pwd, '$1$' . $salt . '$');
                return $hash;
            }
        }

已经有基本级别的暴力保护,3次尝试失败后系统锁定3-5分钟。

对于小型应用程序来说,这是一个好的散列函数吗?

感谢您的帮助。

【问题讨论】:

    标签: php hash passwords crypt


    【解决方案1】:

    不要创建自己的散列。

    PHP 5.5 版有一些 very nice and easy to use password hashing functions,并且有一个库可以将它们向后移植到 PHP 5.3。

    包含它,使用它。完成。

    在此处下载https://github.com/ircmaxell/password_compat 或通过 Composer 包含:

    "require":{
        "ircmaxell/password-compat":"~1.0"
    }
    

    【讨论】:

    • 感谢您的回答。我将研究 password_compact,因为我使用的是 5.4
    • 刚刚使用了 password_compact 并且完美运行。
    猜你喜欢
    • 1970-01-01
    • 2012-12-16
    • 1970-01-01
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 2010-09-28
    相关资源
    最近更新 更多