diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs
index 3ccab3c..9c8c69c 100644
--- a/source/WindowsFormsApplication1/API.cs
+++ b/source/WindowsFormsApplication1/API.cs
@@ -13,6 +13,7 @@
using System.Diagnostics;
using System.Net;
using System.ComponentModel;
+using System.Net.NetworkInformation;
namespace ShiftOS
{
@@ -417,6 +418,23 @@ public static class Encryption
{
private static readonly string passPhrase = "h8gf9dh790df87h9";
+ private static string GetMacAddress()
+ {
+ string macAddresses = string.Empty;
+
+ foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
+ {
+ if (nic.OperationalStatus == OperationalStatus.Up)
+ {
+ macAddresses += nic.GetPhysicalAddress().ToString();
+ break;
+ }
+ }
+
+ return macAddresses;
+ }
+
+
// This constant string is used as a "salt" value for the PasswordDeriveBytes function calls.
// This size of the IV (in bytes) must = (keysize / 8). Default keysize is 256, so the IV must be
// 32 bytes long. Using a 16 character string here gives us 32 bytes when converted to a byte array.
@@ -433,7 +451,7 @@ public static class Encryption
public static string Encrypt(string plainText)
{
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
- using (PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, null))
+ using (PasswordDeriveBytes password = new PasswordDeriveBytes(GetMacAddress(), null))
{
byte[] keyBytes = password.GetBytes(keysize / 8);
using (RijndaelManaged symmetricKey = new RijndaelManaged())
@@ -462,6 +480,38 @@ public static string Encrypt(string plainText)
/// The encrypted string.
/// The decrypted string.
public static string Decrypt(string cipherText)
+ {
+ try
+ {
+ byte[] cipherTextBytes = Convert.FromBase64String(cipherText);
+ using (PasswordDeriveBytes password = new PasswordDeriveBytes(GetMacAddress(), null))
+ {
+ byte[] keyBytes = password.GetBytes(keysize / 8);
+ using (RijndaelManaged symmetricKey = new RijndaelManaged())
+ {
+ symmetricKey.Mode = CipherMode.CBC;
+ using (ICryptoTransform decryptor = symmetricKey.CreateDecryptor(keyBytes, initVectorBytes))
+ {
+ using (MemoryStream memoryStream = new MemoryStream(cipherTextBytes))
+ {
+ using (CryptoStream cryptoStream = new CryptoStream(memoryStream, decryptor, CryptoStreamMode.Read))
+ {
+ byte[] plainTextBytes = new byte[cipherTextBytes.Length];
+ int decryptedByteCount = cryptoStream.Read(plainTextBytes, 0, plainTextBytes.Length);
+ return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch
+ {
+ return Decrypt_old(cipherText);
+ }
+ }
+
+ public static string Decrypt_old(string cipherText)
{
byte[] cipherTextBytes = Convert.FromBase64String(cipherText);
using (PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, null))