Public Shared Function EncryptRSA(ByVal infilename As String, ByVal outfilename As String, ByVal pubkey As String) As String
Dim buffer2 As Byte()
Dim buffer3 As Byte()
Dim provider As New RSACryptoServiceProvider
provider.FromXmlString(File.ReadAllText(pubkey))
Dim sourceArray As Byte() = File.ReadAllBytes(infilename)
Dim num As Integer = (sourceArray.Length / &H3A)
Dim stream As FileStream = File.Create(outfilename)
Dim num2 As Integer = 0
For num2 = 0 To num - 1
buffer2 = New Byte(&H3A - 1) {}
Array.Copy(sourceArray, (num2 * &H3A), buffer2, 0, &H3A)
buffer3 = provider.Encrypt(buffer2, True)
stream.Write(buffer3, 0, buffer3.Length)
Next num2
If ((sourceArray.Length Mod &H3A) <> 0) Then
buffer2 = New Byte((sourceArray.Length Mod &H3A) - 1) {}
Array.Copy(sourceArray, ((sourceArray.Length / &H3A) * &H3A), buffer2, 0, (sourceArray.Length Mod &H3A))
buffer3 = provider.Encrypt(buffer2, True)
stream.Write(buffer3, 0, buffer3.Length)
End If
stream.Close()
Return File.ReadAllText(outfilename)
End Function
错误 1 重载解析失败,因为没有缩小转换就无法调用可访问的“副本”:“公共共享子副本(sourceArray As System.Array,sourceIndex As Long,destinationArray As System.Array,destinationIndex As Long,length As Long)” :参数匹配参数“sourceIndex”从“Double”缩小到“Long”。'公共共享子副本(sourceArray As System.Array,sourceIndex As Integer,destinationArray As System.Array,destinationIndex As Integer,length As Integer)':参数匹配参数 'sourceIndex' 从 'Double' 缩小到 'Integer'。C:\Users\user\AppData\Local\Temporary Projects\WindowsApplication1\Crypto.vb 52 13 WindowsApplication1