vb.net:使用内存流时DES解密错误

时间:2016-04-17 09:53:14

标签: vb.net des

这是我的des解密代码。我不知道为什么它在CopyTo函数上显示错误。

Private Function Unsecure(ByVal sInput As Byte(), ByVal sKey As String)
  'Define the service provider
  Dim DES As New DESCryptoServiceProvider()

  DES.Key() = ASCIIEncoding.ASCII.GetBytes(sKey)
  DES.IV = ASCIIEncoding.ASCII.GetBytes(sKey)

  'Define the crypto transformer
  Dim cryptoTransform As ICryptoTransform

  cryptoTransform = DES.CreateDecryptor 

  Dim ms As New MemoryStream(sInput)   
  Dim cryptostream As New CryptoStream(ms, cryptoTransform, CryptoStreamMode.Read)    
  Dim ms1 As New MemoryStream()

  cryptostream.CopyTo(ms1) '// <- **Error: CopyTo is not a member of System.Security.Cryptography.Cryptostream**

  Return ms1.ToArray()
End Function

0 个答案:

没有答案