Add obfuscation

This commit is contained in:
Kevin Giszewski
2017-09-07 11:01:29 -04:00
parent a54170b915
commit 078f4a506e
2 changed files with 31 additions and 1 deletions
@@ -174,7 +174,9 @@ namespace Archetype.Extensions
archetypeVersion = DllVersion(),
id = ArchetypeGlobalSettings.Instance.Id
}), Encoding.UTF8, "application/json");
client.DefaultRequestHeaders.Add("x-api-key-id", ArchetypeGlobalSettings.Instance.ApiKey.ToString());
var response = client.PostAsync(new Uri(Constants.NotificationUrl), content).Result;
if (response.StatusCode == HttpStatusCode.OK)
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Newtonsoft.Json;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
@@ -11,6 +13,8 @@ namespace Archetype.Models
public bool CheckForUpdates { get; set; }
public Guid Id { get; set; }
public Guid ApiKey = _getApiKey();
private static ArchetypeGlobalSettings _instance;
private static string _pathToConfig = @"~/Config/Archetype.config.js";
@@ -100,5 +104,29 @@ namespace Archetype.Models
_instance.CheckForUpdates = true;
_instance.Save();
}
private static Guid _getApiKey()
{
//this is just obfuscation and an attempt to keep out most but not the determined hacker
var array = new []
{
"RTA4MUZDRjA=",
"NzkzQS1BRDIw",
"OTI3QjFDNjkwQTYy",
"MjI0OQ=="
};
return new Guid(string.Format("{0}-{1}-{3}-{2}",
_decodeBase64(array[0]),
_decodeBase64(array[1]),
_decodeBase64(array[2]),
_decodeBase64(array[3])
));
}
private static string _decodeBase64(string input)
{
return Encoding.UTF8.GetString(Convert.FromBase64String(input));
}
}
}