RE: Conversions to/from Base 64....
MSXML makes it VERY easy to convert back and forth from Base64 and Bytes (which is what you would probably need for this).
I know you guys are talking C+/C#, but here is some VB6 code that will do the conversions back and forth. You should be able to add calls to the MSXML DLL in any language.
I know these work since they are from my AD to VIX conversion pgm. I can't take full credit for these (I found the idea somewhere and modified):
In your project, add a reference to MSXML (I used V6)....
This function takes an array of bytes (8 bit unsigned), and returns it as a base64 string
Code:
Function EncodeBase64(ByRef arrData() As Byte) As String
Dim objXML As MSXML2.DOMDocument ' declare a new document
Dim objNode As MSXML2.IXMLDOMElement ' declare an element
' help from MSXML
Set objXML = New MSXML2.DOMDocument ' create the document
' byte array to base64
Set objNode = objXML.createElement("b64") 'create a new node
objNode.dataType = "bin.base64" ' make it base64
objNode.nodeTypedValue = arrData 'assign the byte data
EncodeBase64 = objNode.Text ' get it back as a string
' thanks, bye
Set objNode = Nothing
Set objXML = Nothing
End Function
This does the DEcoding. If you look, it's identical except it assigns to
the 'text' part of the node, and gets data back from the 'typed value' (bytes). MSXML does ALL the conversions for you.
Code:
Function DecodeBase64(ByVal strData As String) As Byte()
Dim objXML As MSXML2.DOMDocument
Dim objNode As MSXML2.IXMLDOMElement
' help from MSXML
Set objXML = New MSXML2.DOMDocument
Set objNode = objXML.createElement("b64")
objNode.dataType = "bin.base64"
objNode.Text = strData 'this time, take the string data that was passed in
DecodeBase64 = objNode.nodeTypedValue 'and output the byte values
' thanks, bye
Set objNode = Nothing
Set objXML = Nothing
End Function
Bookmarks