This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
|The latest Enterprise Library information can be found at the Enterprise Library site.|
The Cryptography QuickStart includes the following:
- Walkthrough: Encrypting a Secret
- Walkthrough: Decrypting a Secret
- Walkthrough: Getting a Hash Value from Data
- Walkthrough: Checking Whether a Hash Value Matches Some Text
The QuickStart does not require you to perform any setup procedures prior to building and running the application.
The QuickStart is provided in two versions. The first uses the factory approach to create Enterprise Library objects and the static methods. For example, it uses the static EncryptSymmetric method of the Cryptographer class to encrypt the input string.
The second version demonstrates integration with the Unity Application Block. It creates and populates a UnityContainer instance with the data from the <unity> section of the configuration file. This loads the Enterprise Library Core and Cryptography Application Block extensions. This QuickStart also generates the main form instance using the Resolve method of the UnityContainer, which causes Unity to create and inject an instance of the non-static CryptographyManager class in the form constructor. The QuickStart then uses the methods of this instance to perform the tasks required. For example, it uses the EncryptSymmetric method of the CryptographyManager class to encrypt the input string.
For information about integration with the Unity Application Block, and how you can create instances of Enterprise Library objects using Unity, see Creating Objects Using the Unity Application Block.
The QuickStart ships as source code, which means that you must compile it before running it. You use Visual Studio to build the QuickStart.
To build the Cryptography QuickStart
- Ensure that the Enterprise Library Source Code is installed.
- Open the Enterprise Library Source Code folder in Windows Explorer or from the Start menu. To open it from the Start menu, click Start on the taskbar, point to All Programs, point to Microsoft patterns and practices, point to Enterprise Library 4.0 — May 2008, and then click Enterprise Library 4.0 Source Folder.
- To run the factory version of the QuickStart, open the QuickStarts folder, open the Cryptography folder, and then open the CS folder (for C#) or the VB folder (for Visual Basic .NET).
- To run the version of the QuickStart that demonstrates integration with the Unity Application Block, open the QuickStarts folder, open the Cryptography folder, and then open the CS-UnityIntegration folder (for C#) or the VB-UnityIntegration folder (for Visual Basic .NET).
- Double-click the CryptographyQuickStart.sln icon.
- Visual Studio opens, displaying the solution file. Open the Build menu and click Rebuild Solution. By default, this is a debug build.
- Press F5 to run the QuickStart.
The walkthroughs in the Cryptography QuickStart are shipped with a defined configuration, which is included in the App.config file. This file is located in the same folder as the QuickStart project file. Each time you build the code, Visual Studio copies the App.config file to the output directory for the project (the same directory where the QuickStart executable is created), and renames it to CryptographyQuickStart.exe.config.
To change or view these settings, use the Enterprise Library configuration tools to open the App.config file in the directory that contains the QuickStart project file. The App.config file contains the configuration data.
You can also change the application configuration when you do not plan to recompile the application by opening the CryptographyQuickStart.exe.config file with the Enterprise Library configuration tools. However, these changes will be overwritten during the next successful build.
The Cryptography QuickStart contains the following default configuration:
- Hash provider:
- Name: hash provider
- Type: SHA1Managed
- SaltEnabled: True
- Symmetric provider:
- Name: symprovider
- Type: Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.SymmetricAlgorithmProvider
- algorithmType: RijndaelManaged
- protectedKeyFilename: <installdir>\QuickStarts\Cryptography\SymmetricKeyFile.txt
- protectedKeyProtectionScope: LocalMachine
|The QuickStart method CreateKeys generates a key and saves it to this file.|