<bdo id='eBvjP'></bdo><ul id='eBvjP'></ul>
      <legend id='eBvjP'><style id='eBvjP'><dir id='eBvjP'><q id='eBvjP'></q></dir></style></legend>

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

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

        我应该使用什么列类型/长度来在数据库中存储

        时间:2023-08-17
          <bdo id='udSj4'></bdo><ul id='udSj4'></ul>
        • <small id='udSj4'></small><noframes id='udSj4'>

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

                <tfoot id='udSj4'></tfoot>
                    <tbody id='udSj4'></tbody>
                  <i id='udSj4'><tr id='udSj4'><dt id='udSj4'><q id='udSj4'><span id='udSj4'><b id='udSj4'><form id='udSj4'><ins id='udSj4'></ins><ul id='udSj4'></ul><sub id='udSj4'></sub></form><legend id='udSj4'></legend><bdo id='udSj4'><pre id='udSj4'><center id='udSj4'></center></pre></bdo></b><th id='udSj4'></th></span></q></dt></tr></i><div id='udSj4'><tfoot id='udSj4'></tfoot><dl id='udSj4'><fieldset id='udSj4'></fieldset></dl></div>
                  本文介绍了我应该使用什么列类型/长度来在数据库中存储 Bcrypt 哈希密码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想在数据库中存储散列密码(使用 BCrypt).什么是好的类型,哪个是正确的长度?使用 BCrypt 散列的密码是否总是长度相同?

                  I want to store a hashed password (using BCrypt) in a database. What would be a good type for this, and which would be the correct length? Are passwords hashed with BCrypt always of same length?

                  编辑

                  示例哈希:

                  $2a$10$KssILxWNR6k62B7yiX0GAe2Q7wwHlrzhF3LqtVvpyvHZf0MwvNfVu

                  在对一些密码进行散列后,BCrypt 似乎总是生成 60 个字符的散列.

                  After hashing some passwords, it seems that BCrypt always generates 60 character hashes.

                  编辑 2

                  抱歉没有提到实现.我正在使用 jBCrypt.

                  Sorry for not mentioning the implementation. I am using jBCrypt.

                  推荐答案

                  bcrypt 的模块化 crypt 格式包括

                  The modular crypt format for bcrypt consists of

                  • $2$$2a$$2y$ 标识 散列算法和格式
                  • 表示成本参数的两位数值,后跟 $
                  • 一个 53 个字符长的 base-64 编码值(它们使用字母 ./09, AZ, az 与标准 Base 64 编码 字母表)包括:
                    • salt 的 22 个字符(实际上只有 132 个解码位中的 128 个位)
                    • 31 个字符的加密输出(实际上只有 186 个解码位中的 184 个位)
                    • $2$, $2a$ or $2y$ identifying the hashing algorithm and format
                    • a two digit value denoting the cost parameter, followed by $
                    • a 53 characters long base-64-encoded value (they use the alphabet ., /, 09, AZ, az that is different to the standard Base 64 Encoding alphabet) consisting of:
                      • 22 characters of salt (effectively only 128 bits of the 132 decoded bits)
                      • 31 characters of encrypted output (effectively only 184 bits of the 186 decoded bits)

                      因此总长度分别为 59 或 60 字节.

                      Thus the total length is 59 or 60 bytes respectively.

                      当您使用 2a 格式时,您将需要 60 个字节.因此对于 MySQL,我建议使用 CHAR(60) BINARYBINARY(60)(参见 _binbinary 排序规则 以了解区别).

                      As you use the 2a format, you’ll need 60 bytes. And thus for MySQL I’ll recommend to use the CHAR(60) BINARYor BINARY(60) (see The _bin and binary Collations for information about the difference).

                      CHAR 不是二进制安全的,相等性不仅取决于字节值,还取决于实际的排序规则;在最坏的情况下,A 被视为等于 a.参见 _bin 和 <代码>二进制排序规则了解更多信息.

                      CHAR is not binary safe and equality does not depend solely on the byte value but on the actual collation; in the worst case A is treated as equal to a. See The _bin and binary Collations for more information.

                      这篇关于我应该使用什么列类型/长度来在数据库中存储 Bcrypt 哈希密码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:我应该如何处理 MySQL 中的 --secure-file-priv? 下一篇:MySQL:启用 LOAD DATA LOCAL INFILE

                  相关文章

                  最新文章

                  • <bdo id='4aYpj'></bdo><ul id='4aYpj'></ul>

                  <small id='4aYpj'></small><noframes id='4aYpj'>

                  1. <legend id='4aYpj'><style id='4aYpj'><dir id='4aYpj'><q id='4aYpj'></q></dir></style></legend>

                    <tfoot id='4aYpj'></tfoot>

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