O'Reilly logo

Microsoft® .NET Compact Framework Kick Start by Ronnie Yates, Erik Rubin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required