久久久久久久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>
                          主站蜘蛛池模板: 久久久久九九九女人毛片 | 黄色在线免费观看 | 国产精品久久久久久婷婷天堂 | 在线观看国产www | 一级黄色片美国 | 在线观看中文字幕 | 欧美美女爱爱视频 | 国产一级片一区二区三区 | 欧洲精品在线观看 | 久草视频观看 | 性一爱一乱一交一视频 | 国产欧美日韩一区二区三区在线观看 | h在线播放 | 中文字幕视频一区 | 久久精品aaa | 伊人伊成久久人综合网站 | 密色视频 | 国产精品美女www爽爽爽 | 亚洲精品欧美一区二区三区 | 免费观看的av | 青青99| 中文字幕 视频一区 | 碰碰视频 | 亚洲国产精品va在线看黑人 | 欧美在线观看黄色 | 精品欧美一区二区在线观看视频 | 一二三区av | 天天久| 欧美精品一区二区三区在线播放 | 国产在线看片 | 亚洲精品视频免费观看 | 一区二区三区日 | 亚洲视频www | 啪啪网页 | 欧美888| 亚洲美女天堂网 | www.youjizz.com日韩 | 青娱乐国产 | 中文字幕乱码一区二区三区 | 一区二区三区国产视频 | 超碰电影 |