title: Must symmetric keys and initiliazation vectors always be 128, 192, or 256 bits?
body: <p>The following string contains 20 bytes (160 bits).  Do I have to make my keys and initialization vectors 128,192, or 256 or is there something I can do to make it 256 and keep the same key:</p>
  
  <pre><code>    byte[] bbb = Encoding.ASCII.GetBytes("abcdefghijklmnopqrst");
  
  
    // Define other methods and classes here
    static string EncryptStringToBytes(string plainText, string Key, string IV)
      {
          // Check arguments. 
          if (plainText == null || plainText.Length &lt;= 0)
              throw new ArgumentNullException("plainText");
          if (Key == null || Key.Length &lt;= 0)
              throw new ArgumentNullException("Key");
          if (IV == null || IV.Length &lt;= 0)
              throw new ArgumentNullException("Key");
          string encrypted;
          // Create an RijndaelManaged object 
          // with the specified key and IV. 
          using (RijndaelManaged rijAlg = new RijndaelManaged())
          {
              rijAlg.Mode = CipherMode.CBC;
              rijAlg.BlockSize = 256;
              rijAlg.KeySize = 256;
              rijAlg.Key = Encoding.ASCII.GetBytes(Key);
              rijAlg.IV = Encoding.ASCII.GetBytes(IV);
  
              // Create a decrytor to perform the stream transform.
              ICryptoTransform encryptor = rijAlg.CreateEncryptor(rijAlg.Key, rijAlg.IV);
  
              // Create the streams used for encryption. 
              using (MemoryStream msEncrypt = new MemoryStream())
              {
                  using (CryptoStream csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                  {
                      using (StreamWriter swEncrypt = new StreamWriter(csEncrypt))
                      {
  
                          //Write all data to the stream.
                          swEncrypt.Write(plainText);
                      }
                      encrypted = Convert.ToBase64String(msEncrypt.ToArray());
                  }
              }
          }
  
  
          // Return the encrypted bytes from the memory stream. 
          return encrypted;
  
      }
  
      static string DecryptStringFromBytes(string cipherText,string Key, string IV)
      {
          // Check arguments. 
          if (cipherText == null || cipherText.Length &lt;= 0)
              throw new ArgumentNullException("cipherText");
          if (Key == null || Key.Length &lt;= 0)
              throw new ArgumentNullException("Key");
          if (IV == null || IV.Length &lt;= 0)
              throw new ArgumentNullException("Key");
  
          // Declare the string used to hold 
          // the decrypted text.
          string plaintext = null;
  
          // Create an RijndaelManaged object 
          // with the specified key and IV. 
          using (RijndaelManaged rijAlg = new RijndaelManaged())
          {
              rijAlg.Mode = CipherMode.CBC;
              rijAlg.BlockSize = 256;
              rijAlg.KeySize = 256;
              rijAlg.Key = Encoding.ASCII.GetBytes(Key);
              rijAlg.IV = Encoding.ASCII.GetBytes(IV);
  
              // Create a decrytor to perform the stream transform.
              ICryptoTransform decryptor = rijAlg.CreateDecryptor(rijAlg.Key, rijAlg.IV);
  
              // Create the streams used for decryption. 
              using (MemoryStream msDecrypt = new MemoryStream(Convert.FromBase64String(cipherText)))
              {
                  using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                  {
                      using (StreamReader srDecrypt = new StreamReader(csDecrypt))
                      {
  
                          // Read the decrypted bytes from the decrypting stream 
                          // and place them in a string.
                          plaintext = srDecrypt.ReadToEnd();
  
                      }
                  }
              }
  
          }
  
          return plaintext;
  
      }
  </code></pre>