Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vb.net AES解密错误_Vb.net - Fatal编程技术网

Vb.net AES解密错误

Vb.net AES解密错误,vb.net,Vb.net,您好,我收到此错误:字符之间的填充无效且无法删除,或者填充无效且无法删除 代码是: Public Shared Function Decrypt(ByVal Text As String) As String Dim inputBytes As Byte() = Convert.FromBase64String(Text) Dim resultBytes As Byte() = New Byte(inputBytes.Length + 1) {} Dim Decrypte

您好,我收到此错误:字符之间的填充无效且无法删除,或者填充无效且无法删除

代码是:

Public Shared Function Decrypt(ByVal Text As String) As String
    Dim inputBytes As Byte() = Convert.FromBase64String(Text)
    Dim resultBytes As Byte() = New Byte(inputBytes.Length + 1) {}
    Dim DecryptedText As String = [String].Empty
    Dim Cripto As New RijndaelManaged()

    Using ms As New MemoryStream(inputBytes)
        Using objCryptoStream As New CryptoStream(ms, Cripto.CreateDecryptor(_key, _iv), CryptoStreamMode.Read)
            Using sr As New StreamReader(objCryptoStream, True)
                DecryptedText= sr.ReadToEnd()
            End Using
        End Using
    End Using

    Return DecryptedText
End Function

请帮助我

您的
\u键
\u iv
值来自哪里?我以前收到过这个错误,当时缺少键和初始化向量值。键和iv来自构造函数,您确定它们包含有效值吗?是的,当我在一个表中添加大约1000条记录时会发生错误。我这样做是为了做一系列的测试。当我只添加一条记录时,会正确地解密函数。我现在能说的是,您的代码似乎是正确的。在通话失败时检查所有输入(加密数据、密钥和IV)的值,并检查您没有交换一些值,或者您没有意外地以密码或类似的方式传递纯文本。