久久久久久久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麻豆的观看方式 | 日韩精品在线播放 | 免费久久久 | 亚洲三级免费看 | 亚洲成人久久久 | 黄色一级大片在线观看 | 日韩精品一区二区三区免费观看 | 欧美日韩精品免费观看 | 精品国产欧美一区二区三区成人 | 亚洲免费毛片 | 中文在线播放 | 无码一区二区三区视频 | 日本成人免费观看 | 中文字幕成人在线 | 国产片侵犯亲女视频播放 | 久久精品免费一区二区三 | 一区精品在线观看 | 91激情视频 | 日本免费视频 | 日韩免费一区二区 | www.精品国产| 久久久精品国产 | 亚洲一二三区在线观看 | www.久久99| 一区天堂 | 成人永久免费 | 久久精品久久精品久久精品 | а天堂中文最新一区二区三区 | 国内毛片毛片毛片毛片 | 成人av鲁丝片一区二区小说 | 国产一区二 | 亚洲成人毛片 | 午夜天堂精品久久久久 | 国产精彩视频 | 一区二区精品视频 | 91社区在线观看高清 | 欧美日本韩国一区二区三区 | 四虎影视1304t | 久久国产精品一区二区三区 | 国产91精品久久久久久久网曝门 | 青青草一区二区 |