mirror of
https://github.com/greenshot/greenshot
synced 2025-08-14 18:57:28 -07:00
Small stability fixes
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1811 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
9017331dc5
commit
9b7c7a9b7e
4 changed files with 86 additions and 55 deletions
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
|
||||
namespace GreenshotPlugin.Core {
|
||||
public static class EncryptionHelper {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger("EncryptionHelper");
|
||||
private const string RGBIV = "dlgjowejgogkklwj";
|
||||
private const string KEY = "lsjvkwhvwujkagfauguwcsjgu2wueuff";
|
||||
|
||||
|
@ -15,19 +16,23 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="ClearText">the string to call upon</param>
|
||||
/// <returns>an encryped string in base64 form</returns>
|
||||
public static string Encrypt(this string ClearText) {
|
||||
byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText);
|
||||
string returnValue = null;
|
||||
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
|
||||
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV);
|
||||
byte[] key = Encoding.ASCII.GetBytes(KEY);
|
||||
CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write);
|
||||
|
||||
cs.Write(clearTextBytes, 0, clearTextBytes.Length);
|
||||
|
||||
cs.Close();
|
||||
returnValue = Convert.ToBase64String(ms.ToArray());
|
||||
try {
|
||||
byte[] clearTextBytes = Encoding.ASCII.GetBytes(ClearText);
|
||||
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
|
||||
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV);
|
||||
byte[] key = Encoding.ASCII.GetBytes(KEY);
|
||||
CryptoStream cs = new CryptoStream(ms, rijn.CreateEncryptor(key, rgbIV), CryptoStreamMode.Write);
|
||||
|
||||
cs.Write(clearTextBytes, 0, clearTextBytes.Length);
|
||||
|
||||
cs.Close();
|
||||
returnValue = Convert.ToBase64String(ms.ToArray());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.ErrorFormat("Error encrypting, error: ", ex.Message);
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
@ -38,22 +43,26 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="EncryptedText">a base64 encoded rijndael encrypted string</param>
|
||||
/// <returns>Decrypeted text</returns>
|
||||
public static string Decrypt(this string EncryptedText) {
|
||||
byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
|
||||
string returnValue = null;
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
|
||||
|
||||
|
||||
byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV);
|
||||
byte[] key = Encoding.ASCII.GetBytes(KEY);
|
||||
|
||||
CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV),
|
||||
CryptoStreamMode.Write);
|
||||
|
||||
cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length);
|
||||
|
||||
cs.Close();
|
||||
returnValue = Encoding.ASCII.GetString(ms.ToArray());
|
||||
try {
|
||||
byte[] encryptedTextBytes = Convert.FromBase64String(EncryptedText);
|
||||
using (MemoryStream ms = new MemoryStream()) {
|
||||
SymmetricAlgorithm rijn = SymmetricAlgorithm.Create();
|
||||
|
||||
|
||||
byte[] rgbIV = Encoding.ASCII.GetBytes(RGBIV);
|
||||
byte[] key = Encoding.ASCII.GetBytes(KEY);
|
||||
|
||||
CryptoStream cs = new CryptoStream(ms, rijn.CreateDecryptor(key, rgbIV),
|
||||
CryptoStreamMode.Write);
|
||||
|
||||
cs.Write(encryptedTextBytes, 0, encryptedTextBytes.Length);
|
||||
|
||||
cs.Close();
|
||||
returnValue = Encoding.ASCII.GetString(ms.ToArray());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.ErrorFormat("Error decrypting {0}, error: ", EncryptedText, ex.Message);
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
|
|
|
@ -54,25 +54,30 @@ namespace GreenshotPlugin.Core {
|
|||
/// Static initializer for the language code
|
||||
/// </summary>
|
||||
static Language() {
|
||||
if (!LogHelper.isInitialized) {
|
||||
LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)");
|
||||
LogHelper.InitializeLog4NET();
|
||||
}
|
||||
if (!IniConfig.IsInited) {
|
||||
LOG.Warn("IniConfig hasn't been initialized yet! (Design mode?)");
|
||||
IniConfig.Init("greenshot", "greenshot");
|
||||
}
|
||||
string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
// PAF Path
|
||||
AddPath(Path.Combine(applicationFolder, @"App\Greenshot\Languages"));
|
||||
|
||||
// Application data path
|
||||
AddPath(Path.Combine(applicationDataFolder, @"Greenshot\Languages\"));
|
||||
|
||||
// Startup path
|
||||
AddPath(Path.Combine(applicationFolder, @"Languages"));
|
||||
if (!LogHelper.isInitialized) {
|
||||
LOG.Warn("Log4net hasn't been initialized yet! (Design mode?)");
|
||||
LogHelper.InitializeLog4NET();
|
||||
}
|
||||
|
||||
try {
|
||||
string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
|
||||
string applicationFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
||||
|
||||
// PAF Path
|
||||
AddPath(Path.Combine(applicationFolder, @"App\Greenshot\Languages"));
|
||||
|
||||
// Application data path
|
||||
AddPath(Path.Combine(applicationDataFolder, @"Greenshot\Languages\"));
|
||||
|
||||
// Startup path
|
||||
AddPath(Path.Combine(applicationFolder, @"Languages"));
|
||||
} catch (Exception pathException) {
|
||||
LOG.Error(pathException);
|
||||
}
|
||||
|
||||
try {
|
||||
using (RegistryKey languageGroupsKey = Registry.LocalMachine.OpenSubKey(LANGUAGE_GROUPS_KEY, false)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue