Creates an RSA key string in internal format from an XML string.
VB6/VBA
Debug.Print "Testing RSA_FromXMLString ..." Dim strInternalKey As String Dim strXML As String Dim nLen As Long Dim nRet As Long strXML = "<RSAKeyValue>" _ & "<Modulus EncodingType='hexBinary'>0A66791D" _ & "C6988168DE7AB77419BB7FB0C001C627102700751429" _ & "42E19A8D8C51D053B3E3782A1DE5DC5AF4EBE9946817" _ & "0114A1DFE67CDC9A9AF55D655620BBAB</Modulus>" _ & "<Exponent EncodingType='hexBinary'>010001</Exponent>" _ & "</RSAKeyValue>" nLen = RSA_FromXMLString("", 0, strXML, 0) If nLen <= 0 Then MsgBox ("Error: " & nLen) Exit Sub End If strInternalKey = String(nLen, " ") nLen = RSA_FromXMLString(strInternalKey, Len(strInternalKey), strXML, 0) strInternalKey = Left(strInternalKey, nLen) Debug.Print "INTKEY=" & strInternalKey nRet = RSA_CheckKey(strInternalKey, 0) Debug.Print "RSA_CheckKey returns " & nRet
Output
Testing RSA_FromXMLString ... INTKEY=PUBR8P1AetM6PWlPHiFB3B3QUvFsCCJtsWG9uOZmuCI/G3jHxMvHt8i1Cm+o9AYx49krwHaqKBtZZs82L2vT5e7Cpp1Y/jd1mcAmPPzlAkH+Oe97Uc55GhFELdgnxWhdshNc RSA_CheckKey returns 1
VB.NET
Console.WriteLine("Testing RSA_FromXMLString ...")
Dim strInternalKey As String
Dim strXML As String
Dim nRet As Integer
strXML = "<RSAKeyValue>" _
& "<Modulus EncodingType='hexBinary'>0A66791D" _
& "C6988168DE7AB77419BB7FB0C001C627102700751429" _
& "42E19A8D8C51D053B3E3782A1DE5DC5AF4EBE9946817" _
& "0114A1DFE67CDC9A9AF55D655620BBAB</Modulus>" _
& "<Exponent EncodingType='hexBinary'>010001</Exponent>" _
& "</RSAKeyValue>"
strInternalKey = Rsa.FromXMLString(strXML, False)
If strInternalKey.Length = 0 Then
Console.WriteLine("Error: ")
Exit Sub
End If
Console.WriteLine("INTKEY=" & strInternalKey)
nRet = Rsa.CheckKey(strInternalKey)
Console.WriteLine("RSA_CheckKey returns " & nRet)
[Contents]