How to decrypt a Property Bag that been encrypted by using Property Bag Settings in SharePoint

  1. Add a reference. Click Browse, locate the Havivi.PropertyBagSettings.dll on your local drive, and then click OK.

  2. In order to use this assembly in a your application, you simply have to reference it with a #using , as shown here:

    #using Havivi.PropertyBagSettings;

  3. Define the triple des provider, as shown here:
    Havivi.PropertyBagSettings.cTripleDES des = new Havivi.PropertyBagSettings.cTripleDES();

  4. Decrypt the Property Bag, as shown here:

string propertyBagKey = "hello";

string propertyBagValueEncrypt = "";

string propertyBagValueDecrypt = "";
using (SPSite oSPSite = new SPSite(site))


using (SPWeb oSPWeb = oSPSite.OpenWeb(web))


if (oSPWeb.AllProperties.ContainsKey(propertyBagKey))


propertyBagValueEncrypt = oSPWeb.AllProperties[propertyBagKey].ToString();



propertyBagValueDecrypt = des.Decrypt(propertyBagValueEncrypt);

You can download the full source code here:

Web Part Class:


Next Post »
0 Komentar