Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Base64 Encoding Problem
Message
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00640615
Message ID:
00641111
Views:
19
>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 ---
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform