Computing a Hash

The ManagedCryptoAPI class includes a method called ManagedComputeHash, which computes a hash for an array of bytes. To use ManagedComputeHash, follow these steps:

1.
Acquire an instance of the ManagedCryptoAPI class.
2.
Use the ManagedCryptoAPI instance to acquire a handle to a key container within a CSP.
3.
Pass the context handle, the array of bytes for which to compute a hash, and a reference to an Int32 to the ManagedComputeHash method.
4.
ManagedComputeHash returns an array of bytes holding the hash bytes and sets the reference to the Int32 to the number of bytes in the returned array that hold valid hash data.

Listing 14.3, taken from the sample application ComputeHash, demonstrates computing a hash with ManagedCryptoAPI ...

Get Microsoft® .NET Compact Framework Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.