El modo de relleno especificado no es válido para este algoritmo - c # - System.Security.Cryptography

bastante nuevo en C # y actualmente tiene un problema para descifrar contraseñas largas con un error de

La clave especificada no es un tamaño válido para este algoritmo

Sé que esto tiene algo que ver con que la longitud de bits de la contraseña encriptada no es compatible, pero no estoy seguro de cómo proceder con las formas sugeridas para permitir estas contraseñas más largas.

Aquí está mi encriptar y desencriptar

"cipherKey": "0123456789abcdef", "cipherVector": "somereallycooliv"

using System;
using System.Security.Cryptography;
using System.IO;
using System.Text;

namespace DataApi
{
public class Encryption
{
    private readonly IConfigurationService _configService;


    private const string _vector = "cipherVector";
    private const string _key = "cipherKey";

    public Encryption(IConfigurationService configService)
    {
        _configService = configService;
    }
    public string EncryptString(string text)
    {
        if(string.IsNullOrEmpty(text))
        {
            return "";
        }
        try
        {

      var key = Encoding.UTF8.GetBytes(_configService.Get(_key));
        byte[] IV = Encoding.ASCII.GetBytes(_configService.Get(_vector));

        using (var aesAlg = Aes.Create())
        {
            using (var encryptor = aesAlg.CreateEncryptor(key, IV))
            {
                using (var msEncrypt = new MemoryStream())
                {
                    using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
                    using (var swEncrypt = new StreamWriter(csEncrypt))
                    {
                        swEncrypt.Write(text);
                    }

                    var decryptedContent = msEncrypt.ToArray();

                    var result = new byte[IV.Length + decryptedContent.Length];

                    Buffer.BlockCopy(IV, 0, result, 0, IV.Length);
                    Buffer.BlockCopy(decryptedContent, 0, result, IV.Length, decryptedContent.Length);

                    return Convert.ToBase64String(result);
                }
            }
        }
        }
        catch(Exception e) {
             Loggifer.Error("Unable to encrypt string: "+text , e );

            throw e;
        }
    }

    public string DecryptString(string cipherText)
    {
        if(string.IsNullOrEmpty(cipherText))
        {
            return "";
        }
        try
        {
            var fullCipher = Convert.FromBase64String(cipherText);

            byte[] IV = Encoding.ASCII.GetBytes(_configService.Get(_vector));
            var cipher = new byte[16];

            Buffer.BlockCopy(fullCipher, 0, IV, 0, IV.Length);
            Buffer.BlockCopy(fullCipher, IV.Length, cipher, 0, IV.Length);
            var key = Encoding.UTF8.GetBytes(_configService.Get(_key));

            using (var aesAlg = Aes.Create())
            {
                using (var decryptor = aesAlg.CreateDecryptor(key, IV))
                {
                    string result;
                    using (var msDecrypt = new MemoryStream(cipher))
                    {
                        using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
                        {
                            using (var srDecrypt = new StreamReader(csDecrypt))
                            {
                                result = srDecrypt.ReadToEnd();
                            }
                        }
                    }

                    return result;
                }
            }
        }
        catch (Exception e)
        {
            Loggifer.Error("Unable to decrypt string: "+cipherText , e );
            throw e;
        }
    }

}
}

Respuestas a la pregunta(1)

Su respuesta a la pregunta