Walkthrough: Decrypting 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 decrypt text.

To reproduce the demonstration

  1. Declare the appropriate variable and constants.

    const string symmProvider = "symprovider";
    string encryptedContentsBase64;
    
    'Usage
    Const symmProvider As String = "symprovider"
    Dim encryptedContentsBase64 As String
    
  2. Call the static DecryptSymmetric method of the Cryptographer class to perform the decryption, supplying the name of the configured symmetric provider to be used. The following code assumes the member variable encryptedContentsBase64 contains a string that was encrypted using the same symmetric provider.

    string decryptedContents = Cryptographer.DecryptSymmetric(symmProvider, encryptedContentsBase64);
    
    'Usage
    Dim decryptedContents As String = Cryptographer.DecryptSymmetric(symmProvider, encryptedContentsBase64)