Imports System.Security
Imports System.Security.Cryptography
Imports System.Text
Imports System.IO
Public Class Tester
Public Shared Sub Main
Dim myRSAProvide As New RSACryptoServiceProvider()
Dim strCrypt As String
Dim strResult As String
Dim bteCrypt() As Byte
Dim bteResult() As Byte
Try
strCrypt = "12345678"
bteCrypt = Encoding.ASCII.GetBytes(strCrypt)
bteResult = myRSAProvide.Encrypt(bteCrypt, False)
Console.WriteLine(Encoding.ASCII.GetString(bteResult))
Catch ex As CryptographicException
Console.WriteLine(ex.Message)
End Try
Dim strResault As String
Dim bteDecrypt() As Byte
Try
bteDecrypt = myRSAProvide.Decrypt(bteResult, False)
strResault = Encoding.ASCII.GetString(bteDecrypt)
Console.WriteLine(strResault)
Catch ex As CryptographicException
Console.WriteLine(ex.Message)
End Try
End Sub
End Class