Partager via


System.Security.Cryptography - Lots of new stuff in .NET 2.0

Recently I've been working in a BizTalk project where my main task has been to develop a module that is used to help signing and encrypting messages. I have then had the opportunity to dive a bit deeper into the functionality provided by the classes in System.Security.Cryptography.

I have previously worked with some of the classes but I now realize that there are much new functionality in .NET 2.0. Important examples of new functionality are DPAPI and GZIP support.

Data Protection API (DPAPI) is part of the Win32 API and has been available for a long time on WIndows, but using it on .NET has always required using P/Invoke to declare these APIs. Now there is a class called DpapiCryptographer which makes it much easier to use and more accessible to everyone.

GZIP support is provided by GZipStream. Even though the compression ratio could be improved it appears to be fully compatible with other GZIP implementations. In my tests a 45 kB file was compressed to 6.5 kB by GZipStream while using the external tool GZIP.EXE resulted in a 4.5 kB file.

A great resource regarding cryptography in .NET is Shawn's .NET Security Blog, specifically the Cryptograpghy category which is found at https://blogs.msdn.com/shawnfa/archive/category/2868.aspx.