发生错误解密的数据长度无效

问题描述

internal string DecryptData(string iEncryptedText,string aesKey,string iv,int iKeySize = 128)
    {
        PasswordDeriveBytes pdb = new PasswordDeriveBytes(iv,new byte[] { 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F });
        PasswordDeriveBytes pdb2 = new PasswordDeriveBytes(aesKey,new byte[] { 0x49,0x76,0x61,0x6e,0x20,0x4d,0x65,0x64,0x76 });
        RijndaelManaged aesEncryption = new RijndaelManaged();
        aesEncryption.KeySize = iKeySize;
        aesEncryption.BlockSize = 128;
        aesEncryption.Mode = CipherMode.CBC;
        aesEncryption.Padding = PaddingMode.Zeros;
        aesEncryption.IV = pdb.GetBytes(16);
        aesEncryption.Key = pdb2.GetBytes(16); ;
        ICryptoTransform decrypto = aesEncryption.CreateDecryptor();
        byte[] encryptedBytes = Convert.FromBase64Chararray(iEncryptedText.Replace(" ","+").tochararray(),iEncryptedText.Length);
        return Encoding.UTF8.GetString(decrypto.TransformFinalBlock(encryptedBytes,encryptedBytes.Length));


    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)