Rory Primrose

I don't have a solution but I admire the problem

Recent Posts

Tags

Community

Email Notifications

Archives

October 2007 - Posts

Getting the PublicKey for InternalsVisibleTo

Using the InternalsVisibleTo attribute is great for allowing unit tests in an external assembly to directly call types and methods marked as internal. The problem for strong named assemblies is that you need to specify the public key of the unit test assembly in the attribute declaration. I found that David Kean produced a little utility app to make life easy. Thank you very much!

Windows Live Direct Links

I had a bit of a rant earlier about the Windows Live unified installer. Today I came across Long's post about how the installer works and Rafael's x64 pain. Rafael's post lead me to do a search for the WLW installation name of Install_{1F973A7F-3FE4-4D11-A9A2-E869C2899A7D}.msi. This great post came up.

Problem solved.

Microsoft going open source - kind of

A very interesting announcement came out overnight.

Scott Guthrie announced that Microsoft is releasing some of the code of the .Net base class library for the 3.5 framework. License agreement is here with an important note highlighted here.

This has only been previously possible with tools like Reflector which is view only and doesn’t allow debugger support.

Posted: Oct 04 2007, 09:22 AM by Rory Primrose | with no comments
Filed under:
Hashing on the fly

I have been a fan of hashing data for a while, especially for calculating SHA1 checksum values. Until now, I have always had access to the entire set of data that needs to be hashed. Using the SHA1CryptoServiceProvider makes it so easy to build a hash value. You just throw a stream or a byte array at the ComputeHash method.

What if you don't have all the data available? Streaming is the classic example here, especially when you are dealing with a stupid amount of data. It is not wise to hold an entire data set in memory if the amount of data is large. In addition to memory issues, buffering the entire data set while streaming in order to calculate a checksum destroys the point of streaming your data.

Using Reflector to checkout the HashAlgorithm implementation, I thought that there wasn't a way around it as the ComputeHash methods call down to internal methods. After thinking for a while that it wasn't possible to create hash values from chunks of data, I went back and had a look again. Turns out there are publicly available methods to support this. TransformBlock and TransformBlockFinal are the methods to call. I found the naming misleading which is why I previously overlooked them.

With these methods, you can now stream your data in chunks and build a hash value on the fly without needing the entire data set.

Posted: Oct 02 2007, 12:10 PM by Rory Primrose | with no comments
Filed under: