StrataFrame Forum

Using XmlBasics to encrypt a file

http://forum.strataframe.net/Topic13043.aspx

By Greg McGuffey - 12/14/2007

I'm attempting to use the XmlBasics class in the XML namespace of SF. I need to encrypt the file, but am having a bit of trouble figuring out how to do that.



I do not understand how the validation key works, and if it is related to encryption. I also do not understand how the key/vector is set for the encryption of XML files. They seem to be hard coded. I've reviewed the training material from the class and am still confused.



Also, I note that you are using obsolete encryption methods within this class...any reason for that?



Thanks!
By Greg McGuffey - 12/17/2007

bump...
By Trent L. Taylor - 12/18/2007

The validation key is for added security.  We used this for a simple application that we used that launches applications with a different Windows user so that the application could run with Administrative privleges while the logged in user runs as a restricted user.  We did not want the end-user to be able to copy the XML file from one machine to the next, so we used a hash based off of different parts of the machine information to set the validation key.  If it didn't line up, then the XML file could not be read...thus...BOOM Smile  We obviously trapped the error, but it prevented someone from trying to be tricky and added another level of security.

Also, I note that you are using obsolete encryption methods within this class...any reason for that?

This will not be an issue and we use it all of the time.  A while back we realized that we had a bug with the CreateMD5Hash when providing too short of a key.  We could not remove the method as it is used in security as well as other methods (including this one) and it could have a broad impact it we just changed that method.  So we created another that worked as we needed it to and just made the other obsolete so that you would not use it in any new code.  In fact, most of the methods in the XMLBasics have been updated to work outside of the obsolete method, but there were a few that could not be changed as it would have a negative impact on those files already encrypted in the field.

By Greg McGuffey - 12/19/2007

Thanks for the info. I'm still unclear on how to use the validation key. When is it set and how is it used during opening/further writing?
By Trent L. Taylor - 12/20/2007

Greg,

You do not provide a Validation Key when writing the XML file.  It is assigned when the XML file is created.  I have created a sample that shows how to use this logic.  The Xml file is encrypted and used the validation key.  When an invalid Validation Key is provided, we actually prevent the records from being loaded rather than throwing an error.  I wrote a sample on how to use this that you can find here:

http://forum.strataframe.net/FindPost13096.aspx

By Greg McGuffey - 12/20/2007

Alien The solution must be a VS 2008 solution.



I'm going to load up VS 2008 soon...no...really, I've just been busy Blush



(Jeesh, this is a tough crowd to keep up with Tongue )
By Trent L. Taylor - 12/20/2007

Oops...yeah, it was Blush .  I have posted an update that has two solutions...one for each version.  I did write it in 2.0, so that part will work. Smile http://forum.strataframe.net/FindPost13102.aspx
By Greg McGuffey - 12/20/2007

Thanks Trent! And I just installed VS 2008 BigGrin