1

我在 VB.Net 中使用 AES CBC 加密,并使用AS3Crypto完成解密。解密过程中丢失了前几个字符(大约 16 个),并替换为如下所示的随机字符。

05[ÚðÊ\ÃPôôÄ]óbR

这是我的 .net 代码。在 AS3Crypto 演示页面上,我使用 Secret Key > AES > CBC。我尝试使用不同的填充和键格式设置仍然没有运气。

谢谢。

Dim plainText = txt2encrypt.Text.Trim

    Dim encrypted() As Byte        '
    Using aesAlg As New AesCryptoServiceProvider()

        aesAlg.Mode = CipherMode.CBC

        ' Create a decrytor to perform the stream transform. 
        Dim encryptor As ICryptoTransform = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV)
        ' Create the streams used for encryption. 
        Using msEncrypt As New MemoryStream()
            Using csEncrypt As New CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write)
                Using swEncrypt As New StreamWriter(csEncrypt)

                    'Write all data to the stream.
                    swEncrypt.Write(plainText)
                End Using
                encrypted = msEncrypt.ToArray()
            End Using
        End Using

        Dim encryptedText = Convert.ToBase64String(encrypted)

        txtkey.Text = Convert.ToBase64String(aesAlg.Key)
        txtiv.Text = Convert.ToBase64String(aesAlg.IV)
        txtkeysize.Text = aesAlg.KeySize
        txtencrypted.Text = encryptedText
        txtpadding.Text = aesAlg.Padding

    End Using
4

0 回答 0