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

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

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

    2. <tfoot id='CHSWi'></tfoot>

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

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

        對稱加密 (AES):將 IV 和 Salt 與加密數據一起保存是

        Symmetric Encryption (AES): Is saving the IV and Salt alongside the encrypted data safe and proper?(對稱加密 (AES):將 IV 和 Salt 與加密數據一起保存是否安全且正確?)

      1. <tfoot id='t5br2'></tfoot>

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

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

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

                1. 本文介紹了對稱加密 (AES):將 IV 和 Salt 與加密數據一起保存是否安全且正確?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  限時送ChatGPT賬號..

                  I am trying to make sense of how to handle and manage an initilization vector and salt (when applicable) when encrypting and decrypting data using a symmetric encryption algorithm, in this case AES.

                  I have deduced from different SO threads and various other websites that neither the IV or salt need to be secret, only unique in order to defend against cryptanalytic attacks such as a brute-force attack. With this in mind I figured that it would be viable to store my pseudo random IV with the encrypted data. I am asking if the method I am using is proper and furthermore, should I be treating my currently hard coded salt in the same manner? That being writing it to the memory stream along side the IV

                  My code:

                  private const ushort ITERATIONS = 300;
                  private static readonly byte[] SALT = new byte[] { 0x26, 0xdc, 0xff, 0x00, 0xad, 0xed, 0x7a, 0xee, 0xc5, 0xfe, 0x07, 0xaf, 0x4d, 0x08, 0x22,  0x3c };
                  
                  private static byte[] CreateKey(string password, int keySize)
                  {
                      DeriveBytes derivedKey = new Rfc2898DeriveBytes(password, SALT, ITERATIONS);
                      return derivedKey.GetBytes(keySize >> 3);
                  }
                  
                  public static byte[] Encrypt(byte[] data, string password)
                  {
                      byte[] encryptedData = null;
                      using (AesCryptoServiceProvider provider = new AesCryptoServiceProvider())
                      {
                          provider.GenerateIV();
                          provider.Key = CreateKey(password, provider.KeySize);
                          provider.Mode = CipherMode.CBC;
                          provider.Padding = PaddingMode.PKCS7;
                  
                          using (MemoryStream memStream = new MemoryStream(data.Length))
                          {
                              memStream.Write(provider.IV, 0, 16);
                              using (ICryptoTransform encryptor = provider.CreateEncryptor(provider.Key, provider.IV))
                              {
                                  using (CryptoStream cryptoStream = new CryptoStream(memStream, encryptor, CryptoStreamMode.Write))
                                  {
                                      cryptoStream.Write(data, 0, data.Length);
                                      cryptoStream.FlushFinalBlock();
                                  }
                              }
                              encryptedData = memStream.ToArray();
                          }
                      }
                      return encryptedData;
                  }
                  
                  public static byte[] Decrypt(byte[] data, string password)
                  {
                      byte[] decryptedData = new byte[data.Length];
                      using (AesCryptoServiceProvider provider = new AesCryptoServiceProvider())
                      {
                          provider.Key = CreateKey(password, provider.KeySize);
                          provider.Mode = CipherMode.CBC;
                          provider.Padding = PaddingMode.PKCS7;
                          using (MemoryStream memStream = new MemoryStream(data))
                          {
                              byte[] iv = new byte[16];
                              memStream.Read(iv, 0, 16);
                              using (ICryptoTransform decryptor = provider.CreateDecryptor(provider.Key, iv))
                              {
                                  using (CryptoStream cryptoStream = new CryptoStream(memStream, decryptor, CryptoStreamMode.Read))
                                  {
                                      cryptoStream.Read(decryptedData, 0, decryptedData.Length);
                                  }
                              }
                          }
                      }
                      return decryptedData;
                  }
                  

                  I am also open to any other information about symmetric encryption with regards to proper practice.

                  解決方案

                  Storing the IV and Salt along with the cipher text is proper and a best practice. Hard coding the salt is not useful, being random is important, hard coding the iterations is perfectly okay but is typically much higher than 300 (in fact at least 1000 and you typically go much higher if your machine/usage can handle it as in 10s of thousands).

                  Because I've seen so many bad (or old) examples of c# encryption from stack overflow cut and paste into open source code, I wrote a short bit of cut and paste encryption code Modern Examples of Symmetric Authenticated Encryption of a string. that i try to keep up to date and reviewed. It stores the iv and salt with the ciphertext it also authenticates the ciphertext and values included with the cipher text.

                  Ideally though a better practice would be to use a high level encryption library that would handle best practices like the iv for you, however those typically haven't existed for csharp. I've been working on a native csharp version of google's keyczar library. While it's functionally ready for use, I've been wanting to get more eyes on the code before the first official stable release.

                  這篇關于對稱加密 (AES):將 IV 和 Salt 與加密數據一起保存是否安全且正確?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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)
                    <tbody id='KMwPg'></tbody>

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

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

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

                        <tfoot id='KMwPg'></tfoot>
                          <bdo id='KMwPg'></bdo><ul id='KMwPg'></ul>

                          • 主站蜘蛛池模板: 久久网一区二区三区 | 亚洲一区二区三区在线视频 | 国产午夜精品一区二区三区嫩草 | www.亚洲视频| 日韩在线免费观看视频 | 久久国产成人精品国产成人亚洲 | 国产精品欧美一区二区三区 | 久久精品亚洲精品国产欧美 | 日韩精品一区二区三区在线观看 | 国产美女视频黄a视频免费 国产精品福利视频 | 手机av在线 | 国产在线不卡 | 999国产视频 | 国产美女视频一区 | 国产精品色哟哟网站 | 日韩久久久久久 | 久久综合成人精品亚洲另类欧美 | 亚洲欧美国产精品久久 | 国产精品一区二区视频 | 国产1区| 国产精品亚洲精品 | 国产成人精品一区二区三区四区 | 91精品久久| 精品成人av | 国产精品欧美精品日韩精品 | 日韩高清一区 | 羞羞视频网站在线观看 | www.天天干.com| www.久久精品视频 | 伊人春色在线 | 日韩欧美高清dvd碟片 | 人人看人人搞 | 亚洲中午字幕 | 一级毛片色一级 | 在线婷婷| 久久久久久国产精品免费免费狐狸 | 亚洲国产欧美日韩 | 久久精品亚洲精品国产欧美kt∨ | 午夜羞羞 | 热久久久久 | 激情毛片 |