指定的密钥不是此算法的有效大小。没有别的工作

Specified key is not a valid size for this algorithm. Nothing else worked

所以在谷歌搜索了 2 个多小时后,我还没有真正找到解决这个问题的任何有效方法。我正在尝试加密 link,但它每次都向我显示这个错误。

声明:

                        if (F != null)
                        {
                            text = text.Replace("string license", "string license = @\"" + Convert.ToBase64String(F) + "\"");
                        }

加密:

        {
            try
            {
                Aes aes = new AesManaged
                {
                    Key = new byte[] {},
                    IV = new byte[16],
                    Mode = CipherMode.CBC,
                    Padding = PaddingMode.Zeros
                };
                ICryptoTransform crypto;
                crypto = aes.CreateEncryptor();
                return crypto.TransformFinalBlock(message, 0, message.Length); //return encrypted value
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
                return null;
            }
        }

感谢您的回答。

我认为您的密钥需要 16 个字节长。 new byte[] {} 将创建一个 0 字节长的 Key