Posted by : Alon Havivi Tuesday, March 01, 2011

  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: http://pbs.codeplex.com/SourceControl/changeset/view/63103#1139174

Solution: http://pbs.codeplex.com/SourceControl/changeset/changes/63103

Popular Post

- Copyright © Alon Havivi's Blog -