Since you want to encrypt only part of your XML file, you'll need to do something like this for each element you want to protect.
1. Use the UnicodeEncoding class to convert the string you want to encrypt into an array of byte.
2. Use the RijndaelManaged (pronounced "Rain-Doll") class to encrypt the byte array. You'll need two additional byte arrays: One for the key, and one for the initialization vector (makes the key more unique). Protect both these values, as you'll need them to decrypt.
3. Use the ToBase64String method on the Convert class to change the resulting encrypted byte array into something that can be stored in XML.
4. Write the string to your XML DOM.
To decrypt:
1. Read the base64 encoded string from the XML
2. Use the FromBase64String method on the Convert class to change it to a byte array.
3. Use the RijndaelManaged class to decrypt the byte array to a cleartext byte array. You'll need the key and initialization vector used to encrypt it.
4. Use the UnicodeEncoding class to convert the byte array back into a string.
Hope this helps.
Chip H.
____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first