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

<small id='8rmC3'></small><noframes id='8rmC3'>

  • <i id='8rmC3'><tr id='8rmC3'><dt id='8rmC3'><q id='8rmC3'><span id='8rmC3'><b id='8rmC3'><form id='8rmC3'><ins id='8rmC3'></ins><ul id='8rmC3'></ul><sub id='8rmC3'></sub></form><legend id='8rmC3'></legend><bdo id='8rmC3'><pre id='8rmC3'><center id='8rmC3'></center></pre></bdo></b><th id='8rmC3'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='8rmC3'><tfoot id='8rmC3'></tfoot><dl id='8rmC3'><fieldset id='8rmC3'></fieldset></dl></div>

    <legend id='8rmC3'><style id='8rmC3'><dir id='8rmC3'><q id='8rmC3'></q></dir></style></legend>
    <tfoot id='8rmC3'></tfoot>

          <bdo id='8rmC3'></bdo><ul id='8rmC3'></ul>

        “壞數據"加密異常

        quot;Bad Dataquot; CryptographicException(“壞數據加密異常)

        <tfoot id='alXEI'></tfoot>
            • <bdo id='alXEI'></bdo><ul id='alXEI'></ul>

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

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

                1. 本文介紹了“壞數據"加密異常的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  首先,我僅出于學術目的編寫以下代碼.我之所以這么說是因為我沒有把它放在生產環境中,因此我繞過"了一些我需要做的開銷,我只需要能夠使用加密/解密字符串下面的代碼.有幾次我能夠做到這一點,但由于某種原因,我開始收到CryptographicException Bad Data"并且不確定是什么導致了問題.

                  First, I have only written the code below for academic purposes. The reason I say this is because I am not putting this in a production environment, and therefor am "bypassing" some of the overhead that I would need to do if I was, I simply need to be able to encrypt/decrypt a string using the code below. I was able to do it a few time, but for some reason, I started receiving "CryptographicException Bad Data" and am not sure what might be causing the problem.

                     private string RSAEncrypt(string value)
                      {
                          byte[] encryptedData = Encoding.Unicode.GetBytes(value);
                  
                          CspParameters cspParams = new CspParameters();
                          cspParams.KeyContainerName = _rsaContainerName;
                          using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
                          {
                              encryptedData = RSA.Encrypt(encryptedData, false);
                              return Convert.ToBase64String(encryptedData);
                  
                          }
                  
                      }
                  
                  
                  
                      private string RSADecrypt(string value)
                      {
                  
                          byte[] encryptedData = Encoding.Unicode.GetBytes(value);
                  
                          CspParameters cspParams = new CspParameters();
                          cspParams.KeyContainerName = _rsaContainerName;
                          using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
                          { 
                              encryptedData = RSA.Decrypt(encryptedData,false);
                              return Convert.ToBase64String(encryptedData);
                  
                          }
                      }
                  

                  它只是在 RSADecrypt 調用上拋出這個異常.

                  It is only throwing this exception on the RSADecrypt call.

                  有什么想法嗎?我在某處讀到它可能與傳遞給 RSA.Decrypt 的 encryptedData 的預期大小有關.

                  Any ideas? I read somewhere it might have to do with the expected size of encryptedData that is passed into RSA.Decrypt.

                  謝謝}

                  推薦答案

                  • 使用字符串編碼(即Encoding.Unicode)來回轉換明文.

                    使用 Base-64 來回轉換加密數據(即 Convert.[To/From]Base64String);

                    Convert the encrypted data back and forth using Base-64 (i.e. Convert.[To/From]Base64String);

                    像這樣:

                    private string RSAEncrypt(string value)
                    {
                        byte[] plaintext = Encoding.Unicode.GetBytes(value);
                    
                        CspParameters cspParams = new CspParameters();
                        cspParams.KeyContainerName = _rsaContainerName;
                        using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
                        {
                            byte[] encryptedData = RSA.Encrypt(plaintext, false);
                            return Convert.ToBase64String(encryptedData);
                        }
                    }
                    
                    private string RSADecrypt(string value)
                    {
                        byte[] encryptedData = Convert.FromBase64String(value);
                    
                        CspParameters cspParams = new CspParameters();
                        cspParams.KeyContainerName = _rsaContainerName;
                        using (RSACryptoServiceProvider RSA = new RSACryptoServiceProvider(2048,cspParams))
                        { 
                            byte[] decryptedData = RSA.Decrypt(encryptedData,false);
                            return Encoding.Unicode.GetString(decryptedData);
                        }
                    }
                    

                    這篇關于“壞數據"加密異常的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)

                        • <small id='g32js'></small><noframes id='g32js'>

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

                            <tbody id='g32js'></tbody>

                        • <tfoot id='g32js'></tfoot>
                            <bdo id='g32js'></bdo><ul id='g32js'></ul>
                          • 主站蜘蛛池模板: 中文字幕 国产精品 | 久久专区| 永久看片 | 国产精品久久久久久久久久久免费看 | 极品粉嫩国产48尤物在线播放 | 久久一 | 精品国产精品 | 国产精品一卡二卡三卡 | 不卡视频在线 | 中文字幕 国产 | 国产欧美精品一区二区三区 | 日韩在线一区二区三区 | 亚洲网站在线观看 | 欧美久久视频 | 亚洲成人精品 | 成人精品一区二区三区中文字幕 | 国产精品久久精品 | 四虎精品在线 | 国产一区在线免费观看 | 久久国产精品一区二区 | 亚洲午夜精品视频 | 国产一区不卡在线观看 | 中文字幕在线第二页 | 国产精品揄拍一区二区久久国内亚洲精 | h视频在线免费 | 男女网站免费观看 | 国产 欧美 日韩 一区 | 2018国产大陆天天弄 | av手机在线播放 | www久久99| 久久国产精品久久久久久久久久 | 一区二区三区视频在线 | 国产美女h视频 | 91成人免费电影 | 免费在线看黄视频 | 国产精品综合久久 | 色综合天天网 | 日韩av在线不卡 | 日韩在线免费 | 久久精品视频亚洲 | 天天成人综合网 |