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 ...不同的结果?

      C# SHA-1 vs. PHP SHA-1...Different Results?(C# SHA-1 与 PHP SHA-1 ...不同的结果?)
    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 ...不同的结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

              • <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>

                      <tbody id='ghIBi'></tbody>

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

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