****************************使用方法**********************************
Dim pubkey_n As String = "Modulus"
Dim pubkey_e As String = "Exponent"
dim hdata as strint="加密数据"
Dim RSAencBytes() As Byte = rsaEncrypt(pubkey_n, pubkey_e, hdata)
****************************函数定义**********************************
Private Function rsaEncrypt(ByVal pubkey_n As String, ByVal pubkey_e As String, ByVal content As String)
Dim pubkey As String
pubkey = String.Format("<RSAKeyValue><Modulus>{0}</Modulus><Exponent>{1}</Exponent></RSAKeyValue>", Convert.ToBase64String(HexToByte(pubkey_n)), Convert.ToBase64String(HexToByte(pubkey_e)))
Dim rsa As RSACryptoServiceProvider = New RSACryptoServiceProvider()
Dim cipherbytes() As Byte
rsa.FromXmlString(pubkey)
cipherbytes = rsa.Encrypt(Encoding.UTF8.GetBytes(content), False)
Return cipherbytes
End Function