ccc125l87l92l206cad32
fy53999
飞快的心情fy53999

****************************使用方法**********************************

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

posted on 2019-11-05 23:08  fy53999  阅读(147)  评论(0编辑  收藏  举报