<legend id='sEk9Z'><style id='sEk9Z'><dir id='sEk9Z'><q id='sEk9Z'></q></dir></style></legend>
    <i id='sEk9Z'><tr id='sEk9Z'><dt id='sEk9Z'><q id='sEk9Z'><span id='sEk9Z'><b id='sEk9Z'><form id='sEk9Z'><ins id='sEk9Z'></ins><ul id='sEk9Z'></ul><sub id='sEk9Z'></sub></form><legend id='sEk9Z'></legend><bdo id='sEk9Z'><pre id='sEk9Z'><center id='sEk9Z'></center></pre></bdo></b><th id='sEk9Z'></th></span></q></dt></tr></i><div id='sEk9Z'><tfoot id='sEk9Z'></tfoot><dl id='sEk9Z'><fieldset id='sEk9Z'></fieldset></dl></div>

    1. <tfoot id='sEk9Z'></tfoot>

      <small id='sEk9Z'></small><noframes id='sEk9Z'>

        <bdo id='sEk9Z'></bdo><ul id='sEk9Z'></ul>

    2. 如何在 MySQL 的 `encrypt` 函数中使用 `bcrypt` 算法来验证密码?

      How to use `bcrypt` algorithm within `encrypt` function in MySQL for verifying password?(如何在 MySQL 的 `encrypt` 函数中使用 `bcrypt` 算法来验证密码?)

          <tbody id='ZAzcr'></tbody>
      1. <i id='ZAzcr'><tr id='ZAzcr'><dt id='ZAzcr'><q id='ZAzcr'><span id='ZAzcr'><b id='ZAzcr'><form id='ZAzcr'><ins id='ZAzcr'></ins><ul id='ZAzcr'></ul><sub id='ZAzcr'></sub></form><legend id='ZAzcr'></legend><bdo id='ZAzcr'><pre id='ZAzcr'><center id='ZAzcr'></center></pre></bdo></b><th id='ZAzcr'></th></span></q></dt></tr></i><div id='ZAzcr'><tfoot id='ZAzcr'></tfoot><dl id='ZAzcr'><fieldset id='ZAzcr'></fieldset></dl></div>

        <legend id='ZAzcr'><style id='ZAzcr'><dir id='ZAzcr'><q id='ZAzcr'></q></dir></style></legend>

        <small id='ZAzcr'></small><noframes id='ZAzcr'>

      2. <tfoot id='ZAzcr'></tfoot>

              <bdo id='ZAzcr'></bdo><ul id='ZAzcr'></ul>

                本文介绍了如何在 MySQL 的 `encrypt` 函数中使用 `bcrypt` 算法来验证密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我有密码(qwe)的 bcrypted 值($2y$10$zQaDT8hXM4pLmBdwN0xEseda/oKJAQKMKMzUrV8jbs6Epz28BXzBS).但是当我验证时,我得到了错误的结果哈希值.

                I have bcrypted value($2y$10$zQaDT8hXM4pLmBdwN0xEseda/oKJAQKMKMzUrV8jbs6Epz28BXzBS) of password (qwe). But when I am verifying I am getting wrong result hash value.

                mysql> select '$2y$10$zQaDT8hXM4pLmBdwN0xEseda/oKJAQKMKMzUrV8jbs6Epz28BXzBS' = encrypt('qwe', '$2y$10$zQaDT8hXM4pLmBdwN0xEseda/oKJAQKMKMzUrV8jbs6Epz28BXzBS') as is_valid; 
                +----------+
                | is_valid |
                +----------+
                |        0 |
                +----------+
                
                select encrypt('qwe', '$2y$10$zQaDT8hXM4pLmBdwN0xEseda/oKJAQKMKMzUrV8jbs6Epz28BXzBS') as hash;
                +---------------+
                | hash          |
                +---------------+
                | $2tBKnsbV2Szg |
                +---------------+
                

                md5 工作正常

                mysql> select '$1$$.dCRcHz4ApIYzcA0g/qz3/' = encrypt('qwe', '$1$$.dCRcHz4ApIYzcA0g/qz3/') as is_valid; 
                +----------+
                | is_valid |
                +----------+
                |        1 |
                +----------+
                

                如何为 MySQL 添加对 bcrypt 的支持?

                How to add support of bcrypt to MySQL?

                推荐答案

                你不能.MySQL ENCRYPT() 函数使用操作系统的 crypt() 函数——如果你的操作系统不支持 bcrypt 哈希,MySQL 也不支持它们.

                You can't. The MySQL ENCRYPT() function uses the operating system's crypt() function — if your operating system does not support bcrypt hashes, MySQL will not support them either.

                另外,不要使用 MySQL ENCRYPT() 函数.正如 ircmaxell 所指出的,您传递给 MySQL 查询的任何数据都可能最终出现在服务器日志文件中,因此将其用于任何与密码相关的事情可能是不安全的.

                Also, do not use the MySQL ENCRYPT() function. As ircmaxell noted, any data you pass to a MySQL query may end up in server log files, so it's potentially unsafe to use it for anything password-related.

                这篇关于如何在 MySQL 的 `encrypt` 函数中使用 `bcrypt` 算法来验证密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Set the variable result, from query(设置变量结果,来自查询)
                What is dynamic SQL?(什么是动态 SQL?)
                Mysql - How to quit/exit from stored procedure(Mysql - 如何退出/退出存储过程)
                Does MySQL have time-based triggers?(MySQL 有基于时间的触发器吗?)
                is it possible to call a sql script from a stored procedure in another sql script?(是否可以从另一个 sql 脚本中的存储过程调用 sql 脚本?)
                Procedure to loop through comma separated string is not working(遍历逗号分隔字符串的过程不起作用)
                <i id='txjmL'><tr id='txjmL'><dt id='txjmL'><q id='txjmL'><span id='txjmL'><b id='txjmL'><form id='txjmL'><ins id='txjmL'></ins><ul id='txjmL'></ul><sub id='txjmL'></sub></form><legend id='txjmL'></legend><bdo id='txjmL'><pre id='txjmL'><center id='txjmL'></center></pre></bdo></b><th id='txjmL'></th></span></q></dt></tr></i><div id='txjmL'><tfoot id='txjmL'></tfoot><dl id='txjmL'><fieldset id='txjmL'></fieldset></dl></div>

                  <bdo id='txjmL'></bdo><ul id='txjmL'></ul>
                    <tfoot id='txjmL'></tfoot>
                  1. <small id='txjmL'></small><noframes id='txjmL'>

                        <legend id='txjmL'><style id='txjmL'><dir id='txjmL'><q id='txjmL'></q></dir></style></legend>
                          <tbody id='txjmL'></tbody>