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

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

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

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

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

      C# SHA-1 与 PHP SHA-1 ...不同的结果?

      时间:2023-12-01
    3. <legend id='Uc6PH'><style id='Uc6PH'><dir id='Uc6PH'><q id='Uc6PH'></q></dir></style></legend>

          1. <tfoot id='Uc6PH'></tfoot>
              <tbody id='Uc6PH'></tbody>

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

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

              • <bdo id='Uc6PH'></bdo><ul id='Uc6PH'></ul>

              • 本文介绍了C# SHA-1 与 PHP SHA-1 ...不同的结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试从字符串计算 SHA-1 哈希,但是当我使用 php 的 sha1 函数计算字符串时,我得到的结果与我在 C# 中尝试时不同.我需要 C# 来计算与 PHP 相同的字符串(因为来自 php 的字符串是由我无法修改的第 3 方计算的).如何让 C# 生成与 PHP 相同的哈希?谢谢!!!

                I am trying to calculate a SHA-1 Hash from a string, but when I calculate the string using php's sha1 function I get something different than when I try it in C#. I need C# to calculate the same string as PHP (since the string from php is calculated by a 3rd party that I cannot modify). How can I get C# to generate the same hash as PHP? Thanks!!!

                字符串 = s934kladfklada@a.com

                String = s934kladfklada@a.com

                C# 代码(生成 d32954053ee93985f5c3ca2583145668bb7ade86)

                C# Code (Generates d32954053ee93985f5c3ca2583145668bb7ade86)

                        string encode = secretkey + email;
                        UnicodeEncoding UE = new UnicodeEncoding();
                        byte[] HashValue, MessageBytes = UE.GetBytes(encode);
                        SHA1Managed SHhash = new SHA1Managed();
                        string strHex = "";
                
                        HashValue = SHhash.ComputeHash(MessageBytes);
                        foreach(byte b in HashValue) {
                            strHex += String.Format("{0:x2}", b);
                        }
                

                PHP 代码(生成 a9410edeaf75222d7b576c1b23ca0a9af0dffa98)

                PHP Code (Generates a9410edeaf75222d7b576c1b23ca0a9af0dffa98)

                sha1();
                

                推荐答案

                使用 ASCIIEncoding 而不是 UnicodeEncoding.PHP 使用 ASCII 字符集进行哈希计算.

                Use ASCIIEncoding instead of UnicodeEncoding. PHP uses ASCII charset for hash calculations.

                这篇关于C# SHA-1 与 PHP SHA-1 ...不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何在 PHP 中使用 bcrypt 对密码进行哈希处理? 下一篇:使用 php 进行三重 DES 加密/解密

                相关文章

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

                  <tfoot id='ghIBi'></tfoot>

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