Added the possibility to automatically encrypt/decrypt a configuration value by setting "Encrypted" in the ini to true. Also added a small OAuth example in the ImgurUtils, for later usage.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2014 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-09-09 13:53:53 +00:00
parent b2ea24fd9a
commit 79cbe548b0
4 changed files with 41 additions and 2 deletions

View file

@ -22,6 +22,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
using GreenshotPlugin.Core;
namespace Greenshot.IniFile {
/// <summary>
@ -141,6 +142,12 @@ namespace Greenshot.IniFile {
IniValue iniValue = Values[fieldName];
try {
iniValue.SetValueFromProperties(properties);
if (iniValue.Attributes.Encrypted) {
string stringValue = iniValue.Value as string;
if (stringValue != null && stringValue.Length > 2) {
iniValue.Value = stringValue.Decrypt();
}
}
} catch (Exception ex) {
LOG.Error(ex);
}
@ -166,7 +173,20 @@ namespace Greenshot.IniFile {
writer.WriteLine("[{0}]", IniSectionAttribute.Name);
foreach (IniValue value in Values.Values) {
if (value.Attributes.Encrypted) {
string stringValue = value.Value as string;
if (stringValue != null && stringValue.Length > 2) {
value.Value = stringValue.Encrypt();
}
}
// Write the value
value.Write(writer, onlyProperties);
if (value.Attributes.Encrypted) {
string stringValue = value.Value as string;
if (stringValue != null && stringValue.Length > 2) {
value.Value = stringValue.Decrypt();
}
}
}
} finally {
AfterSave();