>I'm kind of twisted on this, I'd really aprpeciate your comments.
>
>I am trying to encrypt a block of data and then put that inside an XML document. When I encrypt, I am sure there are some Chr(0)'s and more in there along with the visible ASCII; my solution was to base64 encode it, but this I think I am either (1) bloating my package unnecessarily or (2) just not doing it right. I'm doing some WinSock-socket communication so I just can't use HTTPS.
>
>What would be the proper number of steps or methods to encrypt/obscure data in an XML document while keeping it as slim as possible?
>
>Thanks.
If you want binary data in your XML document you don't need to encode it yourself. The parser will take care of it for you as long as you provide it with a SafeArray (CreateBinary()).
Here's what i used as a wrapper prior to VFP 7.0 to create base64 encoded content using the XML parser:
LPARAMETERS lcInput, loXML
LOCAL loXML, loNode
IF VARTYPE(loXML) # "O"
loXML = CREATEOBJECT(XML_XMLDOM_PROGID)
loXML.Async = .F.
ENDIF
loXML.loadXML("<node></node>")
loNode = loXML.DocumentElement
loNode.dataType = "bin.base64"
loNode.nodeTypedValue = CREATEBINARY(lcInput)
RETURN Extract(loNode.XML,[">],[</node>])
As you can see the parser will automagically create the Base64 encoded content and does so efficiently.
Yes it'll bloat - Base64 baloons data by 2.4 times (or something like that).
+++ Rick ---