ASPX login page and xml

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

Hi,

I am creating a login part on my page and I wanted to store the username and
password info in a xml file at the server.
But to make sure nobody but my program can read the xml file, I was thinking
of using some kind of encryption.

How can I do this?
Is there any known and easy way to do this?

rg,
Eric
 
This article discusses ways of encrypting and decrypting an XML file:

http://www.fawcette.com/vsm/2003_03/magazine/features/vandersypen/default_pf.aspx


Dim filename As String = _
"c:\SymmetricExample.xml"

Dim FileWriter As FileStream = New _
FileStream(filename,FileMode.Create)

Dim CryptoWriter As CryptoStream = _
New CryptoStream(FileWriter, _
cryptoprovider.CreateEncryptor( _
key,iv), CryptoStreamMode.Write)

This code creates a stream for decrypting a file:

Dim filename As String = _
"c:\SymmetricExample.xml"

Dim FileReader As FileStream = New _
FileStream(filename, FileMode.Open)

Dim CryptoReader As CryptoStream = _
New CryptoStream(FileReader, _
cryptoprovider.CreateDecryptor( _
key,iv), CryptoStreamMode.Read)

Now that you have a stream for encrypting and decrypting data, you can feed
it into an XmlTextReader object for decrypting or an XmlTextWriter object
for encrypting:

Dim XmlDoc As XmlDocument

Dim XmlReader As XmlTextReader = New _
XmlTextReader(CryptoReader)

XmlDoc = New XmlDocument()

XmlDoc.Load(XmlReader)
 
Thank you!!!

rg,
eric.

Ken Cox said:
This article discusses ways of encrypting and decrypting an XML file:

http://www.fawcette.com/vsm/2003_03/magazine/features/vandersypen/default_pf.aspx


Dim filename As String = _
"c:\SymmetricExample.xml"

Dim FileWriter As FileStream = New _
FileStream(filename,FileMode.Create)

Dim CryptoWriter As CryptoStream = _
New CryptoStream(FileWriter, _
cryptoprovider.CreateEncryptor( _
key,iv), CryptoStreamMode.Write)

This code creates a stream for decrypting a file:

Dim filename As String = _
"c:\SymmetricExample.xml"

Dim FileReader As FileStream = New _
FileStream(filename, FileMode.Open)

Dim CryptoReader As CryptoStream = _
New CryptoStream(FileReader, _
cryptoprovider.CreateDecryptor( _
key,iv), CryptoStreamMode.Read)

Now that you have a stream for encrypting and decrypting data, you can feed
it into an XmlTextReader object for decrypting or an XmlTextWriter object
for encrypting:

Dim XmlDoc As XmlDocument

Dim XmlReader As XmlTextReader = New _
XmlTextReader(CryptoReader)

XmlDoc = New XmlDocument()

XmlDoc.Load(XmlReader)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top