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作爲System.array,sourceIndex長, 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:\用戶\用戶名\應用程序數據\本地\臨時項目\ WindowsApplication1 \ Crypto.vb 52 13 WindowsApplication1Array.copy方法
這不是崩潰。這是一個編譯錯誤。 – 2012-04-18 20:01:26