Encrypting and Decrypting Data by Using a Password
Encrypting and decrypting data is achieved by calling CryptEncrypt and CryptDecrypt. These two functions require as an input a handle to a key that is used for encrypting or decrypting the data. The easiest way to get a handle to a key is to derive one using a password. This section discusses how to perform encryption and decryption by deriving the keys with passwords.
The simplest way to perform encryption and decryption with a password is to use the ManagedCryptoAPI class to do all of the work for you. To encrypt data using a password as the encryption key, follow these steps:
1. | Acquire an instance of the ManagedCryptoAPI class. |
2. | Acquire byte arrays for text to encrypt and acquire the text ... |
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.