Persisting a dataset as encrypted XML

I had to revisit this functionality today. I am pretty certain that I tested decrypting back to a dataset with the previous method I was using, but today it just wouldn’t work at all. After a lot of reading, googling and research, I learned a lot about various methods of cryptography, yet I was still unable to solve my problem on my own. Finally I came upon a code sample (not in the first 4 searches, mind you!) and thought I better persist THAT here!! Here is the link. If for some reason that link goes away here’s my particular (VB.Net) treatment of the code:

Public Sub encryptDS(ByVal ds As DataSet, ByVal filename As String)
Dim aCryptoStream As
CryptoStream
Try
 Dim aXmlTextWriter As
XmlTextWriter
 aXmlTextWriter = New
XmlTextWriter(filename, Text.Encoding.UTF8)
 Dim aUE As New
Text.UnicodeEncoding
 Dim keyBytes() As Byte
= {……} ‘your secret bytes go here
 Dim RMCrypto As RijndaelManaged = New
RijndaelManaged
 aCryptoStream = New
CryptoStream(aXmlTextWriter.BaseStream,  RMCrypto.CreateEncryptor(keyBytes, keyBytes), CryptoStreamMode.Write)
 
ds.WriteXml(aCryptoStream)
Catch ex As
Exception
 …
Finally
 aCryptoStream.Close()
End Try
End Sub

Public Sub DecryptDS(ByRef ds As DataSet, ByVal filename As String)
 Dim aFileStream As New
FileStream(filename, FileMode.Open)
 Dim aStreamReader As
StreamReader
 Try
  aStreamReader = New
StreamReader(aFileStream)
  Dim aUE As New
Text.UnicodeEncoding
  Dim keyBytes() As Byte
= {….} ‘ your secret bytes go here
  Dim RMCrypto As RijndaelManaged = New
RijndaelManaged
  Dim aCryptoStream As New CryptoStream(aFileStream,
  RMCrypto.CreateDecryptor(keyBytes, keyBytes), CryptoStreamMode.Read)
  ‘Restore the data set
  ds.ReadXml(aCryptoStream)
 Catch exS As
IOException
  …
 Catch ex As
Exception
  …
 Finally
  aStreamReader.Close()
  aFileStream.Close()
 End Try
End Sub

 

Blogging Evolution

I find it interesting to watch the larger scope of how blogging in our community is evolving. A few to note: Shelley Powers bags the blog roll (which made me realize that I still haven’t bothered “creating” mine on this site after almost a month), removal of comment options to many blogs (notable to me is Sam Gentile), a desire and new comfort level for people to expose more sides of themselves in their blogs (Sam again, is another example as am I in my move from the weblogs.asp.net – though there are just so many examples coming on every day). Some more thoughts on this – without comments people are starting to have more conversations via their blogs (this is not new, just growing). I am unsure about this from a selfish perspective. Sometimes I’d much prefer to leave a comment rather than create a web post of my own in order to comment on something. But then this creates more links and Shelley says that links speak MUCH louder than a list (blogroll) that probably gets outdated pretty quickly. As I have gotten to know many bloggers in the past year, I love reading more about their personal lives. Even reading Don Box (though he’s not someone I really know personally) suddenly talking about his 3 kids and their favorite xmas present. When we see someone like Don in front of an audience of 8,000 doing his “thing” – who stops to think that this is a man with a life outside of Microsoft – a father with little kids? That to me is an important part of what community is about – not just getting access to technical information overload. Well, there seems to be another focus that has been interesting to me also which I see a lot of in Raymond Chen’s blog (on what a pain in the ass it is to try to keep everyone happy all of the time – orchestrating the dance that is Microsoft’s OS working with so many varieties of software) and have always loved about Laura Johns’ blog (often about how things tick at Microsoft). Anyway – just some random thoughts. Back to work…

Blogging APIs and passwords

Here are two things that I noticed about the blogger and metaweblog api’s that were of interest that I have to look further into. First, the metaweblog passes up a combination of strings and structures. I want to experiment with passing structs to a webservice.  In both blogger and metaweblog, one of the strings that are passed up is a password. I have to dig further into how these are working on the client end and on the server end because there must be something else happening on the client end to encrypt or do something to the password before just sending it up as a string, right?

My big sister

This is my big sister, Jill. It’s funny that at 42, I still refer to her, my older sister by only a few years, as “my big sister”, but she is still the mother hen of us three siblings. My sister worked as a Sun corporate and institutional sales rep for many years and was very successful. She’s a phenomenal sales person and business woman. She finally had it with high pressure and high tech and left (before the bust) and started her own business. SHe manufactures dog “toys” – not just to play with but for working dogs as well. Within one year, she had her product in nearly 200 stores. RIght now she is in nearly 500 stores (that’s 2 years). I helped her out by doing a website for her when she started out which is pretty cute. It’s just Frontpage and some asp, but she had some great ideas about how it should be organized and I played with the design until I was satisfied enough to put my name on it. That’s www.katiesbumpers.com. But really I wrote this because she just sent me some pics for the site and included some beautiful pictures of her and one of hte products, a bag for the dog toys, called the “Oval Office” (for all your important stuff). And I just wanted to show her off and show off her awesome products which she researched and designed on her own. Though we had the usual rough time in our teens that most siblings do, Jill and I are very very close now and I know that I’m so fortunate to have that kind of relationship with her.