- Add a reference. Click Browse, locate the Havivi.PropertyBagSettings.dll on your local drive, and then click OK.
- 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; - Define the triple des provider, as shown here:
Havivi.PropertyBagSettings.cTripleDES des = new Havivi.PropertyBagSettings.cTripleDES(); - 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
0 Komentar