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

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

    1. <legend id='3cBBz'><style id='3cBBz'><dir id='3cBBz'><q id='3cBBz'></q></dir></style></legend>

      <tfoot id='3cBBz'></tfoot>

      <small id='3cBBz'></small><noframes id='3cBBz'>

      • <bdo id='3cBBz'></bdo><ul id='3cBBz'></ul>

        RijndaelManaged“填充無效,無法移除"僅在生產

        RijndaelManaged quot;Padding is invalid and cannot be removedquot; that only occurs when decrypting in production(RijndaelManaged“填充無效,無法移除僅在生產中解密時發生)
          <bdo id='xw55N'></bdo><ul id='xw55N'></ul>
            <tfoot id='xw55N'></tfoot>

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

            <legend id='xw55N'><style id='xw55N'><dir id='xw55N'><q id='xw55N'></q></dir></style></legend>

                  <tbody id='xw55N'></tbody>
                  本文介紹了RijndaelManaged“填充無效,無法移除"僅在生產中解密時發生的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  我知道有人對此提出了其他問題,但到目前為止沒有一個問題提供解決方案或正是我遇到的問題.

                  I know other questions have been asked on this but none so far have provided a solution or are exactly the issue I have.

                  下面的類處理字符串的加解密,傳入的key和vector總是一樣的.

                  The class below handles the encryption and decryption of strings, the key and vector passed in are ALWAYS the same.

                  被加密和解密的字符串總是數字,大多數工作但偶爾解密時失敗(但僅在生產服務器上).我應該提到,本地和生產環境都在 Windows Server 2003 上的 IIS6 中,使用該類的代碼位于 .ashx 處理程序中.在生產服務器上失敗的例子是0000232668"

                  The strings being encrypted and decrypted are always numbers, most work but the occasional one fails when decrypting (but only on the production server). I should mention that both local and production environments are in IIS6 on Windows Server 2003, the code that uses the class sits in a .ashx handler. The example that fails on the production server is "0000232668"

                  錯誤信息是

                  System.Security.Cryptography.CryptographicException:填充無效且無法刪除.在 System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)

                  System.Security.Cryptography.CryptographicException: Padding is invalid and cannot be removed. at System.Security.Cryptography.RijndaelManagedTransform.DecryptData(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode paddingMode, Boolean fLast)

                  對于代碼

                   public class Aes
                      {
                          private byte[] Key;
                          private byte[] Vector;
                  
                          private ICryptoTransform EncryptorTransform, DecryptorTransform;
                          private System.Text.UTF8Encoding UTFEncoder;
                  
                          public Aes(byte[] key, byte[] vector)
                          {
                              this.Key = key;
                              this.Vector = vector;
                  
                              // our encyption method
                              RijndaelManaged rm = new RijndaelManaged();
                  
                              rm.Padding = PaddingMode.PKCS7;
                  
                              // create an encryptor and decyptor using encryption method. key and vector
                              EncryptorTransform = rm.CreateEncryptor(this.Key, this.Vector);
                              DecryptorTransform = rm.CreateDecryptor(this.Key, this.Vector);
                  
                              // used to translate bytes to text and vice versa
                              UTFEncoder = new System.Text.UTF8Encoding();
                          }
                  
                          /// Encrypt some text and return a string suitable for passing in a URL. 
                          public string EncryptToString(string TextValue)
                          {
                              return ByteArrToString(Encrypt(TextValue));
                          }
                  
                          /// Encrypt some text and return an encrypted byte array. 
                          public byte[] Encrypt(string TextValue)
                          {
                              //Translates our text value into a byte array. 
                              Byte[] bytes = UTFEncoder.GetBytes(TextValue);
                              Byte[] encrypted = null;
                  
                              //Used to stream the data in and out of the CryptoStream. 
                              using (MemoryStream memoryStream = new MemoryStream())
                              {                
                                  using (CryptoStream cs = new CryptoStream(memoryStream, EncryptorTransform, CryptoStreamMode.Write))
                                  {
                                      cs.Write(bytes, 0, bytes.Length);                    
                                  }
                  
                                  encrypted = memoryStream.ToArray();                
                              }
                  
                              return encrypted;
                          }
                  
                          /// The other side: Decryption methods 
                          public string DecryptString(string EncryptedString)
                          {
                              return Decrypt(StrToByteArray(EncryptedString));
                          }
                  
                          /// Decryption when working with byte arrays.     
                          public string Decrypt(byte[] EncryptedValue)
                          {
                              Byte[] decryptedBytes = null;
                  
                              using (MemoryStream encryptedStream = new MemoryStream())
                              {
                                  using (CryptoStream decryptStream = new CryptoStream(encryptedStream, DecryptorTransform, CryptoStreamMode.Write))
                                  {
                                      decryptStream.Write(EncryptedValue, 0, EncryptedValue.Length);
                                  }
                  
                                  decryptedBytes = encryptedStream.ToArray();
                              }
                  
                              return UTFEncoder.GetString(decryptedBytes);
                          }
                  
                          /// Convert a string to a byte array.  NOTE: Normally we'd create a Byte Array from a string using an ASCII encoding (like so). 
                          //      System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding(); 
                          //      return encoding.GetBytes(str); 
                          // However, this results in character values that cannot be passed in a URL.  So, instead, I just 
                          // lay out all of the byte values in a long string of numbers (three per - must pad numbers less than 100). 
                          public byte[] StrToByteArray(string str)
                          {
                              if (str.Length == 0)
                                  throw new Exception("Invalid string value in StrToByteArray");
                  
                              byte val;
                              byte[] byteArr = new byte[str.Length / 3];
                              int i = 0;
                              int j = 0;
                              do
                              {
                                  val = byte.Parse(str.Substring(i, 3));
                                  byteArr[j++] = val;
                                  i += 3;
                              }
                              while (i < str.Length);
                              return byteArr;
                          }
                  
                          // Same comment as above.  Normally the conversion would use an ASCII encoding in the other direction: 
                          //      System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 
                          //      return enc.GetString(byteArr);     
                          public string ByteArrToString(byte[] byteArr)
                          {
                              byte val;
                              string tempStr = "";
                              for (int i = 0; i <= byteArr.GetUpperBound(0); i++)
                              {
                                  val = byteArr[i];
                                  if (val < (byte)10)
                                      tempStr += "00" + val.ToString();
                                  else if (val < (byte)100)
                                      tempStr += "0" + val.ToString();
                                  else
                                      tempStr += val.ToString();
                              }
                              return tempStr;
                          }
                  

                  感謝您的所有幫助,但是您的回答并沒有解決問題,結果證明這是非常簡單的事情.我在一臺服務器上生成了一個加密字符串,并將其交給另一臺服務器上的處理程序進行解密和處理,但事實證明,在不同服務器上運行時加密的結果不同,因此接收服務器無法解密它.其中一個答案偶然發現了這個提示,這就是我接受它的原因

                  Thankyou for all of your help however your answers did not un-cover the problem, which turned out to be something stupidly simple. I was generating an encrypted string on one server and handing it over to a handler on another server for decrpytion and processing, but it turns out that the results of encryption differ when run on different servers, hence the receiving server could not decrypt it. One of the answers stumbled across the hint at this by accident, which is why I accepted it

                  推薦答案

                  當加密和解密由于某種原因沒有使用相同的密鑰或初始化向量時,有時會收到有關無效填充的消息.填充是添加到明文末尾的一些字節,以使其組成完整數量的塊以供密碼處理.在 PKCS7 填充中,每個字節都等于添加的字節數,因此在解密后始終可以將其刪除.您的解密導致最后一個 n 個字節不等于最后一個字節的值 n 的字符串(希望這句話有意義).所以我會仔細檢查你所有的鑰匙.

                  You will sometimes get a message about invalid padding when encryption and decryption for whatever reason have not used the same key or initialisation vector. Padding is a number of bytes added to the end of your plaintext to make it up to a full number of blocks for the cipher to work on. In PKCS7 padding each byte is equal to the number of bytes added, so it can always be removed after decryption. Your decryption has led to a string where the last n bytes are not equal to the value n of the last byte (hope that sentence makes sense). So I would double check all your keys.

                  或者,在您的情況下,我建議您確保為每個加密和解密操作創建和處置 RijndaelManagedTransform 的實例,并使用密鑰和向量對其進行初始化.這個問題很可能是重用這個transform對象造成的,也就是說第一次使用后,它就不再是正確的初始狀態了.

                  Alternatively, in your case, I would suggest making sure that you create and dispose an instance of RijndaelManagedTransform for each encryption and decryption operation, initialising it with the key and vector. This problem could very well be caused by reusing this transform object, which means that after the first use, it is no longer in the right initial state.

                  這篇關于RijndaelManaged“填充無效,無法移除"僅在生產中解密時發生的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  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)
                  ASP.net C# Gridview ButtonField onclick event(ASP.net C# Gridview ButtonField onclick 事件)
                  Adding OnClick event to ASP.NET control(將 OnClick 事件添加到 ASP.NET 控件)
                  Multiple submit Button click problem?(多個提交按鈕點擊問題?)
                  <legend id='zXm03'><style id='zXm03'><dir id='zXm03'><q id='zXm03'></q></dir></style></legend>

                    <bdo id='zXm03'></bdo><ul id='zXm03'></ul>

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

                          1. 主站蜘蛛池模板: 成人在线视频一区 | 日韩一| 91中文字幕 | 91精品国产乱码久久久久久久久 | 日韩一区二区在线观看视频 | 欧美日本亚洲 | 国产成人精品999在线观看 | www国产成人免费观看视频,深夜成人网 | 国产精品久久av | 欧美精品一区二区三区在线 | 国产精品免费一区二区三区四区 | 欧美一级www片免费观看 | 99久久精品国产一区二区三区 | 国内精品视频 | 狠狠色狠狠色综合日日92 | 男女激情网站免费 | 国产精品一区二区三区免费观看 | 欧美日韩在线播放 | 亚洲高清在线 | 亚洲精品一级 | 午夜影院操| 天天躁日日躁性色aⅴ电影 免费在线观看成年人视频 国产欧美精品 | 久久国产精品免费一区二区三区 | 国产精品久久一区二区三区 | 99re视频在线免费观看 | 欧美一区免费 | 风间由美一区二区三区在线观看 | 欧美日韩国产高清视频 | 精品一区二区在线观看 | 国产二区视频 | 免费v片 | 精品www| 成年人网站免费 | 精品久久久久久亚洲精品 | 国产片侵犯亲女视频播放 | 一区二区三区 在线 | 国产精品美女久久久av超清 | 欧美一区视频 | 精品欧美一区二区三区精品久久 | 亚洲毛片在线 | 国产精品电影网 |