944,048 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 1881
  • VB.NET RSS
Oct 18th, 2005
0

NO value was pass over to it..

Expand Post »
When i run the program at the WebApplication.. the error is "An unhandled exception of type 'System.ExecutionEngineException' occurred in mscorlib.dll"

Web service Code:
Dim xmlKeys As String 'A combination of both the public and private keys
Dim xmlPublicKey As String 'The public key only
Dim PlainTextBArray As Byte() 'The plaintext message in a byte array
Dim CypherTextBArray As Byte() 'The cyphertext message in a byte array

<WebMethod()> _
Public Function HelloWorld() As String
'Return "Hello World"
'End Function
Dim rsa As New RSACryptoServiceProvider
xmlPublicKey = rsa.ToXmlString(False)
xmlKeys = rsa.ToXmlString(True)
'get the public key so you can encrypt the message:
rsa.FromXmlString(xmlPublicKey)

'get the message
Dim message As String = "hello String"
If message.Length > 58 Then MsgBox("You must use fewer than 59 characters") : Exit Function

'transform message string into a byte array:
PlainTextBArray = (New UnicodeEncoding).GetBytes(message)

' Encrypt
CypherTextBArray = rsa.Encrypt(PlainTextBArray, False)

'view the cyphertext
Dim Enc As String

For i As Integer = 0 To CypherTextBArray.Length - 1
Enc &= Chr(CypherTextBArray(i))
Next i
Return Enc

Web application Code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim test As New localhost.Service1
'TextBox1.Text = test.HelloWorld()

Dim rsa As New RSACryptoServiceProvider
xmlPublicKey = rsa.ToXmlString(False)
xmlKeys = rsa.ToXmlString(True)

'get the keys, thereby creating an RSA object that's identical
'to the one used in the Form_Load event when the keys were first built
rsa.FromXmlString(xmlKeys)

'create a byte array and then put the decrypted plaintext into it
Dim RestoredPlainText As Byte() = rsa.Decrypt(CypherTextBArray, False) << Error Occur at this line..

'Step through the two-byte unicode plaintext, displaying the restored plaintext message
For i As Integer = 0 To (RestoredPlainText.Length - 1) Step 2
TextBox1.Text &= Chr(RestoredPlainText(i))
Next i

End Sub
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
little_imps is offline Offline
1 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: help with vb.net
Next Thread in VB.NET Forum Timeline: Using Windows XP Visual Styles with Controls on Windows Forms





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC