久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

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

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

    2. 在 C# 中使用私鑰對數據進行簽名

      Signing data with private key in c#(在 C# 中使用私鑰對數據進行簽名)

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

      <legend id='2VC0Y'><style id='2VC0Y'><dir id='2VC0Y'><q id='2VC0Y'></q></dir></style></legend>
        <tbody id='2VC0Y'></tbody>

          <tfoot id='2VC0Y'></tfoot>
          • <bdo id='2VC0Y'></bdo><ul id='2VC0Y'></ul>

            • <i id='2VC0Y'><tr id='2VC0Y'><dt id='2VC0Y'><q id='2VC0Y'><span id='2VC0Y'><b id='2VC0Y'><form id='2VC0Y'><ins id='2VC0Y'></ins><ul id='2VC0Y'></ul><sub id='2VC0Y'></sub></form><legend id='2VC0Y'></legend><bdo id='2VC0Y'><pre id='2VC0Y'><center id='2VC0Y'></center></pre></bdo></b><th id='2VC0Y'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2VC0Y'><tfoot id='2VC0Y'></tfoot><dl id='2VC0Y'><fieldset id='2VC0Y'></fieldset></dl></div>
              1. 本文介紹了在 C# 中使用私鑰對數據進行簽名的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                限時送ChatGPT賬號..

                我需要使用算法 SHA1RSA 用一個私鑰對一些數據進行簽名,Rsa 密鑰長度為 2048,基本編碼為 64.我的代碼是這樣的

                I need to sign some data with one private key using Algorithm SHA1RSA ,Rsa Key length 2048 with 64 base encoding.My code is like this

                string sPayload = "";
                HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create("URI");
                httpWebRequest.ContentType = "application/json; charset=utf-8";
                httpWebRequest.Method = WebRequestMethods.Http.Post;
                
                using (StreamWriter streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    sPayload = "{"id":"14123213213"," +
                                ""uid":"teller"," +
                                ""pwd":"abc123"," +
                                ""apiKey":"2343243"," +
                                ""agentRefNo":"234324324"}";
                
                    httpWebRequest.Headers.Add("SIGNATURE", Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(sPayload))));
                    
                    streamWriter.Write(sPayload);
                    streamWriter.Flush();
                    streamWriter.Close();
                }
                
                System.Net.ServicePointManager.Expect100Continue = false;
                
                HttpWebResponse httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                
                using (StreamReader streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    string result = streamReader.ReadToEnd();
                }
                

                在標頭名稱簽名中,我需要使用私鑰傳遞簽名數據(sPayload).但是使用上面的代碼會出現無效簽名"錯誤.來自第三方,我不確定加密部分是否正確.

                In the Header name Signature i need to pass the signed data(sPayload) using the private key.But using above code an error is getting as "invalid signature" from third party and i'am not sure whether the Encryption part is correct or not.

                httpWebRequest.Headers.Add("SIGNATURE", Convert.ToBase64String(new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(Encoding.ASCII.GetBytes(sPayload))));
                

                第三方提供了一個證書(cert,sha1)和密鑰.我應該參考代碼嗎?

                Third party had provide one certificate(cert,sha1) and key.should i refer that to the code?

                推薦答案

                您計算了 sPayload 的 SHA-1 哈希,而不是 RSA-SHA1 簽名.

                You have computed the SHA-1 hash of sPayload, not the RSA-SHA1 signature.

                如果您有 X509Certificate2:

                If you have an X509Certificate2:

                using (RSA rsa = cert.GetRSAPrivateKey())
                {
                    return rsa.SignData(sPayload, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
                }
                

                如果您已經擁有原始 RSA 密鑰,那么請不要使用 using 語句.

                If you already have a raw RSA key then just leave off the using statement.

                如果你必須計算 sPayload 的哈希值,你可以這樣做

                If you have to compute the hash of sPayload for some other reason you can do it like

                byte[] hash;
                byte[] signature;
                
                using (HashAlgorithm hasher = SHA1.Create())
                using (RSA rsa = cert.GetRSAPrivateKey())
                {
                    hash = hasher.ComputeHash(sPayload);
                    signature = rsa.SignHash(hash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
                }
                

                SignHash 仍然需要 HashAlgorithmName 值,因為算法標識符嵌入在簽名中.

                SignHash still requires the HashAlgorithmName value because the algorithm identifier is embedded within the signature.

                這篇關于在 C# 中使用私鑰對數據進行簽名的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                What are good algorithms for vehicle license plate detection?(車牌檢測有哪些好的算法?)
                onClick event for Image in Unity(Unity中圖像的onClick事件)
                Running Total C#(運行總 C#)
                Deleting a directory when clicked on a hyperlink with JAvascript.ASP.NET C#(單擊帶有 JAvascript.ASP.NET C# 的超鏈接時刪除目錄)
                asp.net listview highlight row on click(asp.net listview 在單擊時突出顯示行)
                Calling A Button OnClick from a function(從函數調用按鈕 OnClick)
              2. <small id='iMWSE'></small><noframes id='iMWSE'>

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

                      <tfoot id='iMWSE'></tfoot>

                        • <i id='iMWSE'><tr id='iMWSE'><dt id='iMWSE'><q id='iMWSE'><span id='iMWSE'><b id='iMWSE'><form id='iMWSE'><ins id='iMWSE'></ins><ul id='iMWSE'></ul><sub id='iMWSE'></sub></form><legend id='iMWSE'></legend><bdo id='iMWSE'><pre id='iMWSE'><center id='iMWSE'></center></pre></bdo></b><th id='iMWSE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='iMWSE'><tfoot id='iMWSE'></tfoot><dl id='iMWSE'><fieldset id='iMWSE'></fieldset></dl></div>
                          主站蜘蛛池模板: 亚洲一区二区免费视频 | 天天射日日干 | 国产成人毛片 | 亚洲激情综合 | 国产成人在线视频 | 麻豆av在线免费观看 | 男人影院在线观看 | 天天视频国产 | 国产一级特黄aaa大片 | 免费h片 | www.日本在线观看 | 亚洲免费在线视频 | 国产成人精品三级麻豆 | 欧洲美一区二区三区亚洲 | 久久久久久久久久久久久久 | 伊人久久亚洲 | 天天天天操| 夜夜狠狠擅视频 | 日韩性生活视频 | 日本一区二区三区四区五区 | 国产三区在线观看 | 日本不卡视频在线观看 | 草草网 | 国产激情一区二区三区 | 一区二区三区在线播放 | brazzers疯狂作爱 | 精品国产乱码久久久久久影片 | 日韩一级免费视频 | 国产小视频网站 | 亚洲第一黄网 | 欧美精品www | 国产区免费 | 91免费福利视频 | 激情五月婷婷丁香 | 伦一理一级一a一片 | 日韩综合精品 | 成人动态视频 | 成人在线国产 | 成人精品福利 | av永久免费 | 欧美精品在线播放 |