vb System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange类(方法)实例源码

下面列出了vb System.Security.Cryptography.RSAPKCS1KeyExchangeDeformatter.DecryptKeyExchange 类(方法)源码代码实例,从而了解它的用法。

作者:VB.NET开发    项目:System.Security.Cryptograph   
Public Sub Receive(ByVal iv() As Byte, ByVal encryptedSessionKey() As Byte, ByVal encryptedMessage() As Byte)

    Dim aes = New AesCryptoServiceProvider()
    Try
        aes.IV = iv

        ' Decrypt the session key
        Dim keyDeformatter As New RSAPKCS1KeyExchangeDeformatter(rsaKey)
        aes.Key = keyDeformatter.DecryptKeyExchange(encryptedSessionKey)

        ' Decrypt the message
        Dim plaintext As New MemoryStream()
        Try
            Dim cs As New CryptoStream(plaintext, aes.CreateDecryptor(), CryptoStreamMode.Write)
            Try
                cs.Write(encryptedMessage, 0, encryptedMessage.Length)
                cs.Close()

                Dim message As String = Encoding.UTF8.GetString(plaintext.ToArray())
                Console.WriteLine(message)
            Finally
                cs.Dispose()
            End Try
        Finally
            plaintext.Dispose()
        End Try
    Finally
        aes.Dispose()
    End Try

End Sub


问题


面经


文章

微信
公众号

扫码关注公众号