错误1:没有为“Public Overridable Function GetString(bytes() As Byte, index As Integer, count As Integer) As String”的参数“count”指定参数。
类的代码如下(红色地方报错):
[code=VB.NET][/code]
Imports System
Imports System.IO
Imports System.Security.Cryptography
Imports System.Text
Public Class Csmode
Public Function Encrypt(ByVal StrInput As String) As String
Dim ByteInput As [Byte]() = Encoding.Default.GetBytes(StrInput)
Dim Ms As New System.IO.MemoryStream
Dim DESC As New DESCryptoServiceProvider
Dim CStream As New CryptoStream(Ms, DESC.CreateEncryptor(Encoding.Default.GetBytes("20000000"), Encoding.Default.GetBytes("字节数量")), CryptoStreamMode.Write)
CStream.Write(ByteInput, 0, ByteInput.Length)
CStream.FlushFinalBlock()
Return Convert.ToBase64String(Ms.ToArray)
End Function
Public Function Decrypt(ByVal StrInput As String) As String
Dim ByteInput As [Byte]() = Convert.FromBase64String(StrInput)
Dim ms As New System.IO.MemoryStream
Dim DESC As New DESCryptoServiceProvider
Dim CStream As New CryptoStream(ms, DESC.CreateDecryptor(Encoding.Default.GetBytes("20000000"), Encoding.Default.GetBytes("字节数量")), CryptoStreamMode.Write)
CStream.Write(ByteInput, 0, ByteInput.Length)
CStream.FlushFinalBlock()
Return Encoding.Default.GetString(ms.ToArray())
End Function
End Class
------解决方案--------------------
大概是下面的写法即可,因为wince上的GetString方法没有只有一个参数的重载
Return Encoding.Default.GetString(ms.ToArray(),0,ms.ToArray().length)