title: Does base64 encoding has any string length limit to encode?
body: <p>I have tab application which converts password using Base64 encoding. It is send to web application via web service where it gets decoded. Code for decoding is,</p>
  
  <pre><code>public static string DecryptStringPassword(string base64StringToDecrypt)
          {
              //Set up the encryption objects
              using (AesCryptoServiceProvider acsp = GetProvider(Encoding.Default.GetBytes(Key)))
              {
                  byte[] RawBytes = Convert.FromBase64String(base64StringToDecrypt);
                  ICryptoTransform ictD = acsp.CreateDecryptor();
  
                  //RawBytes now contains original byte array, still in Encrypted state
  
                  //Decrypt into stream
                  MemoryStream msD = new MemoryStream(RawBytes, 0, RawBytes.Length);
                  CryptoStream csD = new CryptoStream(msD, ictD, CryptoStreamMode.Read);
                  //csD now contains original byte array, fully decrypted
  
                  //return the content of msD as a regular string
                  return (new StreamReader(csD)).ReadToEnd();
              }
          }
  
          private static AesCryptoServiceProvider GetProvider(byte[] key)
          {
              AesCryptoServiceProvider result = new AesCryptoServiceProvider();
              result.BlockSize = 128;
              result.KeySize = 128;
              result.Mode = CipherMode.CBC;
              result.Padding = PaddingMode.PKCS7;
  
              result.GenerateIV();
              result.IV = new byte[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  
              byte[] RealKey = GetKey(key, result);
              result.Key = RealKey;
              // result.IV = RealKey;
              return result;
          }
  
          private static byte[] GetKey(byte[] suggestedKey, SymmetricAlgorithm p)
          {
              byte[] kRaw = suggestedKey;
              List&lt;byte&gt; kList = new List&lt;byte&gt;();
  
              for (int i = 0; i &lt; p.LegalKeySizes[0].MinSize; i += 8)
              {
                  kList.Add(kRaw[(i / 8) % kRaw.Length]);
              }
              byte[] k = kList.ToArray();
              return k;
          }
  </code></pre>
  
  <p>Is there any maximum character limit for base64 encoding? For one of the passwords "xwYgqg8+xnynU7MpceOoJw==" is the encrypted string which gives exception "padding is invalid and can not be removed" while decoding using above code.
  In the DecryptStringPassword() function, last line, 
  return (new StreamReader(csD)).ReadToEnd(); gives the exception.</p>
  
  <p>Same password I encrypted using AES encryption, it gives me 
  "xwYgqg8+xnynU7MpceOoJ70HuRIIw+OkcDPBVa18mLw=" such a big encrypted password compared to base64 encoding which does not give any exception while decoding.</p>
  
  <p>Is there any limit that base64 encoding gives always 24 characters long encrypted string or any length restriction on the string to be encrypted.</p>
  
  <p>Our one of the users facing this issue while decoding the password. Rest all users have no problem while decoding.</p>