Aracılığıyla paylaş


Adding Application Code

The Cryptography Application Block is designed to support common scenarios for symmetric encryption and hashing. When you add your application code, refer to the scenarios in Key Scenarios and select the ones that best suit your situation. Use the code that accompanies the scenario either as it is shown here or adapt it as needed.

To prepare your application

  1. Add a reference to the Cryptography Application Block assembly. In Visual Studio®, right-click your project node in Solution Explorer, and then click Add Reference. Click Browse to locate the Microsoft.Practices.EnterpriseLibrary.Security.Cryptography.dll assembly. Select the assembly, and then click OK.

  2. Following the same procedure, set a reference to the following assemblies:

    • Microsoft.Practices.EnterpriseLibrary.Common.dll
    • Microsoft.Practices.Unity.dll
    • Microsoft.Practices.ServiceLocation.dll
    • Microsoft.Practices.Unity.Interception.dll
  3. (Optional) To use elements from the Cryptography Application Block without fully qualifying the element reference, you can add the following using statement (C#) or Imports statement (Visual Basic) to the top of your source code file.

    using Microsoft.Practices.EnterpriseLibrary.Security.Cryptography;
    
    'Usage
    Imports Microsoft.Practices.EnterpriseLibrary.Security.Cryptography
    
  4. Next, add the application code.

Note

For Microsoft® Visual Basic® projects, you can also use the References page of the Project Designer to manage references and imported namespaces. To access the References page, select a project node in Solution Explorer, and then click Properties on the Project menu. When the Project Designer appears, click the References tab.