salt + sha512 + md5加密

 追求生活的垃圾筒 发布于 2023-02-05 10:00

我有以下代码:(只是用于加密/散列的测试文件)






  The length of the hashed word is " . $hashLen . " characters long!";
    }

    ?>

    

这有多安全?我知道这很可能是被黑客入侵,但需要多长时间?我目前正在制作一个php/mysqli注册表,并希望尽可能安全地使用户的密码,这样黑客就需要很长时间才能破解用户的密码.为了加密它,我可以使用它,例如:

用sha512,md5(md5),加入不同的盐,两个sha512,另一个md5和另一种不同的盐来混合它!

听起来有多安全?黑客破解密码需要多长时间?请您使用非常非常安全的加密方法告诉我.此外,我想让用户使用cookie登录:需要一种安全的方式将他们的信息存储在cookie中!

提前致谢 :)

1 个回答
  • 这是不安全的.它与Dave的家庭酿造哈希/有点愚蠢的算法类似,答案解释了它的错误.在你的情况下,我只会说你只使用非常快的哈希进行2次计算,而这远远不足以击败基于GPU的破解.

    此外,您永远不应该使用自己的加密技术,当然这也适用于散列函数.而是使用PHP附带的标准且经过良好测试的密码散列函数:

    $password = "HelloStackOverflow"; // example password
    
    $hash = password_hash($password, PASSWORD_BCRYPT); // here's the hash of the previous password
    
    // you can set the "complexity" of the hashing algorithm, it uses more CPU power
    // but it'll be harder to crack, even though the default is already good enough
    
    $hash = password_hash($password, PASSWORD_BCRYPT, ["cost" => 10]); 
    
    if (password_verify($password, $hash)) { // checking if a password is valid
        echo "Welcome back !"; // valid password
    } else {
        echo "You're not the one you're pretending to be..."; // invalid password
    }
    

    如果您的PHP安装太旧(<5.5)并且没有这些password_*功能,您可以使用此库提供与这些功能的向前兼容性; 用法与上面的例子保持一致.

    2023-02-05 10:03 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有