<bdo id='Bl95j'></bdo><ul id='Bl95j'></ul>
    1. <tfoot id='Bl95j'></tfoot>

        <legend id='Bl95j'><style id='Bl95j'><dir id='Bl95j'><q id='Bl95j'></q></dir></style></legend>
      1. <small id='Bl95j'></small><noframes id='Bl95j'>

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

        在 ColdFusion MX7 和 PHP 5.x 上同样工作的哈希函数?

        时间:2023-10-30

          <bdo id='2mjRl'></bdo><ul id='2mjRl'></ul>

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

              1. <legend id='2mjRl'><style id='2mjRl'><dir id='2mjRl'><q id='2mjRl'></q></dir></style></legend>
                  <tbody id='2mjRl'></tbody>
              2. <tfoot id='2mjRl'></tfoot>

                <small id='2mjRl'></small><noframes id='2mjRl'>

                  本文介绍了在 ColdFusion MX7 和 PHP 5.x 上同样工作的哈希函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在处理旧的 ColdFusion MX7 站点.他们想实现一个salted hash"密码系统.但是在明年左右的某个时间,他们计划建立一个全新的 PHP 站点,并且不想重置(丢失)所有密码.

                  I am working on a legacy ColdFusion MX7 site. They want to implement a "salted hash" password system. But some time in the next year or so they plan to build a completely new PHP site and don't want to have to reset (lose) all the passwords.

                  所以我正在寻找一些可以在两个平台上运行的代码.

                  So I'm looking for some code that will work on both platforms.

                  我是新手,但据我所知,以下两个代码块应该做同样的事情.但是,它们会产生不同的结果.有人愿意帮忙吗?

                  I'm new to this, but as far as I can tell, the following two blocks of code should do the same thing. However, they produce different results. Anyone care to help?

                  COLDFUSION 代码:

                  COLDFUSION CODE:

                      <cffunction name="computeHash" access="public" returntype="String">
                          <cfargument name="password" type="string" />
                          <cfargument name="salt" type="string" />
                          <cfargument name="iterations" type="numeric" required="false" default="1024" />
                          <cfargument name="algorithm" type="string" required="false" default="SHA-1" />
                          <cfscript>
                              var hashed = '';
                              hashed = hash( password & salt, arguments.algorithm, 'UTF-8' );
                          </cfscript>
                          <cfloop from="1" to="#iterations#" index="i">
                              <cfscript>
                                  hashed = hash( hashed & salt, arguments.algorithm, 'UTF-8' );
                              </cfscript>
                          </cfloop>
                      </cffunction>
                  

                  PHP 代码:

                      function computeHash($password,$salt)
                      {
                          $hashed = '';
                          $hashed = hash('sha1', $password . $salt);
                          for ($i = 1; $i <= 1024; $i++) 
                          {
                              $hashed = hash('sha1', $hashed . $salt);
                          }
                          echo $hashed;
                      }
                  

                  更新 1:感谢您的回复!使用密码p@ssW0rd"和盐JjXSROiYyKkxNzTklaiErQ=="会生成以下结果:

                  UPDATE 1: Thanks for your replies! Using a password of "p@ssW0rd", and a salt of "JjXSROiYyKkxNzTklaiErQ==" generates the following results:

                  冷融合:

                  代码,第 1 部分:

                  hashed = hash( password & salt, arguments.algorithm, 'UTF-8' );
                  

                  生成:

                  A0A8DE3A3B2A8BFD74766EEE126950F4462D3BCB
                  

                  代码,第 2 部分:

                  hash( hashed & salt, arguments.algorithm, 'UTF-8' );
                  

                  生成:

                  CFF9B75918B75761B5568854782CD709B2941637
                  

                  PHP:

                  代码,第 1 部分:

                  $hashed = hash('sha1', $password . $salt);
                  

                  生成:

                  a0a8de3a3b2a8bfd74766eee126950f4462d3bcb
                  

                  代码,第 2 部分:

                  hash('sha1', $hashed . $salt);
                  

                  生成:

                  e955404423747ec706561fa9a319ddac47194a65
                  

                  如您所见,第一次,输出匹配.但是当我重新哈希时,它们不再匹配.我糊涂了.

                  As you can see, the first time around, the outputs match. But when I re-hash, they no longer match. I'm confused.

                  推荐答案

                  ColdFusion 生成 A0A8DE3A3B2A8BFD74766EEE126950F4462D3BCB

                  ,PHP 生成 a0a8de3a3b2a8bfd74766eee126950f4462d3bcb

                  如您所见,第一次,输出匹配.

                  As you can see, the first time around, the outputs match.

                  这些字符串不相同.您需要将它们都转换为相同的情况 - 我会在 PHP 生成的结果上使用 strtoupper().

                  Those strings are not identical. You need to turn them both to the same case - I would use strtoupper() on PHP's generated result.

                  这篇关于在 ColdFusion MX7 和 PHP 5.x 上同样工作的哈希函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:是否可以运行 Coldfusion &amp;PHP 在同一服务器和网站上? 下一篇:提交表单后如何在后台运行 PHP 脚本?

                  相关文章

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

                • <small id='OAUdM'></small><noframes id='OAUdM'>

                    <tfoot id='OAUdM'></tfoot>

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