By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,244 Members | 1,972 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,244 IT Pros & Developers. It's quick & easy.

Upload XML Files to Server

P: n/a
Hello,

I apologize if this is the wrong forum for this question. If so please
direct me to the correct one.

I have some XML files that are populated in the field with no internet
connection. I would then like to be able to securely upload them to a
wide array of servers - rather seemlessly - and preferably in an
encrypted state.

The criteria is that the end-user does not even know of the existence
of the XML files and that the server being uploaded to is pretty much
out of my control.

Does anyone have any ideas?

Thanx in advance.

Jim

Nov 3 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
FTP (and webdav) are insecure as any passwords used to access the FTP
deamon are also sent in the upload stream unencrypted. But, there are
many other alternatives available to do this.

You could write a webservice to accept the content of your XML; the
service would expose a method such as receiveXML(System.String xml)
that an external program connecting to your webservice can use. This
has the advantage that the webservice can use windows authentication to
control user access.

Both the client and webservice ends can encrypt/decrypt the xml
document before and after it is sent. For example, you can write
routines that XOR a key with the data to make it unreadable:

Public Function EncryptField(ByVal strText As String, ByVal strKey
As String) As String
Dim textlen As Integer = Len(strText)
Dim buffer(textlen) As Byte
Dim keylen As Integer = Len(strKey)

Dim textindex As Integer
Dim keyindex As Integer = 1

For textindex = 1 To textlen
buffer(textindex - 1) = Asc(Mid(strText, textindex, 1)) Xor
Asc(Mid(strKey, keyindex, 1))
keyindex = ((keyindex + 1) Mod keylen) + 1
Next

Return Convert.ToBase64String(buffer, 0, textlen)
End Function

Public Function DecryptField(ByVal strText As String, ByVal strKey
As String) As String
Dim buffer() As Byte = Convert.FromBase64String(strText)
Dim textlen As Integer = buffer.Length
Dim keylen As Integer = Len(strKey)

Dim textindex As Integer
Dim keyindex As Integer = 1
Dim output As String = ""

For textindex = 0 To textlen - 1
output = output + Chr(buffer(textindex) Xor Asc(Mid(strKey,
keyindex, 1)))
keyindex = ((keyindex + 1) Mod keylen) + 1
Next

Return output
End Function
And, to allow your data to cross firewall boundaries safely, you should
send it encdoded in base64 from the client. The following is done
after receiving a post from an HTML INPUT file tag:

Stream xmlStream = hfsXML.PostedFile.InputStream;
BinaryReader xmlReader = new BinaryReader(xmlStream);
System.Byte[] buffer=xmlReader.ReadBytes(10000000); //max 10 megs
encodedXML = Convert.ToBase64String(buffer);
xmlReader.Close();
xmlStream.Close();
Another approach is to use XML parsers on both your client and server
sides and have them talk to each other and transfer the document back
and forth. Depending on the manufacturer of the parser, you maybe able
to have the parser encrypt it for you.

Andy

Nov 3 '06 #2

P: n/a
My head is just slightly spinning.

Thanx for the great tips on the encryption and the heads up on the FTP.

Jim

Nov 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.