diff --git a/GreenshotImgurPlugin/ImgurUtils.cs b/GreenshotImgurPlugin/ImgurUtils.cs
index 63d14f837..c585212d4 100644
--- a/GreenshotImgurPlugin/ImgurUtils.cs
+++ b/GreenshotImgurPlugin/ImgurUtils.cs
@@ -261,5 +261,22 @@ namespace GreenshotImgurPlugin {
} catch {}
}
+
+ private static void ImgurOAuthExample() {
+ OAuthHelper oAuth = new OAuthHelper();
+ oAuth.CallbackUrl = "http://getgreenshot.org";
+ oAuth.AccessTokenUrl = "https://api.imgur.com/oauth/access_token";
+ oAuth.AuthorizeUrl = "https://api.imgur.com/oauth/authorize";
+ oAuth.RequestTokenUrl = "https://api.imgur.com/oauth/request_token";
+ oAuth.ConsumerKey = "907d4455b8c38144d68c4f72190af4c40504a0ac7";
+ oAuth.ConsumerSecret = "d33902ef409fea163ab755454c15b3d0";
+ oAuth.UserAgent = "Greenshot";
+ oAuth.getRequestToken();
+ if (string.IsNullOrEmpty(oAuth.authorizeToken("Imgur authorization"))) {
+ return;
+ }
+ string accessToken = oAuth.getAccessToken();
+ MessageBox.Show(oAuth.oAuthWebRequest(OAuth.Method.GET, "http://api.imgur.com/2/account", null));
+ }
}
}
diff --git a/GreenshotPlugin/Core/EncryptionHelper.cs b/GreenshotPlugin/Core/EncryptionHelper.cs
index 30eb502fd..31b4e5278 100644
--- a/GreenshotPlugin/Core/EncryptionHelper.cs
+++ b/GreenshotPlugin/Core/EncryptionHelper.cs
@@ -36,7 +36,7 @@ namespace GreenshotPlugin.Core {
/// the string to call upon
/// an encryped string in base64 form
public static string Encrypt(this string ClearText) {
- string returnValue = null;
+ string returnValue = ClearText;
try {
byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText);
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
@@ -63,7 +63,7 @@ namespace GreenshotPlugin.Core {
/// a base64 encoded rijndael encrypted string
/// Decrypeted text
public static string Decrypt(this string EncryptedText) {
- string returnValue = null;
+ string returnValue = EncryptedText;
try {
byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
using (MemoryStream ms = new MemoryStream()) {
diff --git a/GreenshotPlugin/IniFile/IniAttributes.cs b/GreenshotPlugin/IniFile/IniAttributes.cs
index b106062b1..5096a28b2 100644
--- a/GreenshotPlugin/IniFile/IniAttributes.cs
+++ b/GreenshotPlugin/IniFile/IniAttributes.cs
@@ -50,6 +50,8 @@ namespace Greenshot.IniFile {
public string Separator = ",";
public string DefaultValue;
public string LanguageKey;
+ // If Encrypted is set to true, the value will be decrypted on load and encrypted on save
+ public bool Encrypted = false;
public bool FixedValue = false;
public bool ExcludeIfNull=false;
diff --git a/GreenshotPlugin/IniFile/IniSection.cs b/GreenshotPlugin/IniFile/IniSection.cs
index 19eea9a0e..9c0cb62c0 100644
--- a/GreenshotPlugin/IniFile/IniSection.cs
+++ b/GreenshotPlugin/IniFile/IniSection.cs
@@ -22,6 +22,7 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.IO;
+using GreenshotPlugin.Core;
namespace Greenshot.IniFile {
///
@@ -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();