Walkthrough: Encrypting a Secret

Retired Content

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.

This walkthrough demonstrates how to use the Cryptography Application Block to encrypt some text.

To reproduce the demonstration

  1. Declare the appropriate variables and constants.
  2. const string symmProvider = "symprovider";
    string stringToEncrypt;
    string encryptedContentsBase64;
    
    
  3. Obtain the text from the user.
  4. stringToEncrypt = "Sample text";
    
    
  5. Call the static EncryptSymmetric method of the Cryptographer class to perform the encryption, supplying the name of the configured symmetric provider to be used.
  6. encryptedContentsBase64 = Cryptographer.EncryptSymmetric(symmProvider, stringToEncrypt);
    
    

Show: