First off, let’s take a quick look at the System.Security.Cryptography namespace, which simply refer to as the Cryptography namespace from this point on. As with most of the .NET namespaces, there are a lot of members to take in at first glance. For example, this namespace has its stream classes (Crypto Stream), abstract hash classes (Hash Algorithm), and symmetric algorithms (RijndaelManaged), among others. The classes were designed to make it easy for the developer to refer to an object at runtime with considerable flexibility. This design allows you to plug in different cryptographic implementations as you see fit. Furthermore, it allows you to add new implementations that either you create or other companies provide. You’ll see throughout this chapter how the various classes work, starting with hash-based classes in the next section.
Cryptographic Exceptions
As you probably know, whenever you code, there’s always the chance something can go wrong. .NET defines two exception classes for Cryptography: CryptographicException and CryptographicUnexpectedOperationException, with the second exception inheriting from the first exception. Unfortunately, their meanings are pretty generic when you review the software development kit (SDK). CryptographicException occurs when a processing error happens, and CryptographicUnexpectedOperationException is raised when an unexpected error occurs.
Leave a Reply