Change Lua encryption key to be the old one.

This commit is contained in:
MichaelTheShifter 2016-07-05 08:41:13 -04:00
parent b5a5e0eb8a
commit a0b001b25f
2 changed files with 29 additions and 2 deletions

View file

@ -474,6 +474,33 @@ public static string Encrypt(string plainText)
} }
} }
public static string Encrypt_old(string plainText)
{
byte[] plainTextBytes = Encoding.UTF8.GetBytes(plainText);
using (PasswordDeriveBytes password = new PasswordDeriveBytes(passPhrase, null))
{
byte[] keyBytes = password.GetBytes(keysize / 8);
using (RijndaelManaged symmetricKey = new RijndaelManaged())
{
symmetricKey.Mode = CipherMode.CBC;
using (ICryptoTransform encryptor = symmetricKey.CreateEncryptor(keyBytes, initVectorBytes))
{
using (MemoryStream memoryStream = new MemoryStream())
{
using (CryptoStream cryptoStream = new CryptoStream(memoryStream, encryptor, CryptoStreamMode.Write))
{
cryptoStream.Write(plainTextBytes, 0, plainTextBytes.Length);
cryptoStream.FlushFinalBlock();
byte[] cipherTextBytes = memoryStream.ToArray();
return Convert.ToBase64String(cipherTextBytes);
}
}
}
}
}
}
/// <summary> /// <summary>
/// Decrypts an encrypted string. /// Decrypts an encrypted string.
/// </summary> /// </summary>

View file

@ -399,8 +399,8 @@ public void RegisterCore()
mod.get_codepoints = new Func<int>(() => GetCP()); mod.get_codepoints = new Func<int>(() => GetCP());
mod.buy_upgrade = new Func<string, bool>((id) => BuyUPG(id)); mod.buy_upgrade = new Func<string, bool>((id) => BuyUPG(id));
mod.time = new Func<string>(() => API.GetTime()); mod.time = new Func<string>(() => API.GetTime());
mod.encrypt = new Func<string, string>((raw) => API.Encryption.Encrypt(raw)); mod.encrypt = new Func<string, string>((raw) => API.Encryption.Encrypt_old(raw));
mod.decrypt = new Func<string, string>((raw) => API.Encryption.Decrypt(raw)); mod.decrypt = new Func<string, string>((raw) => API.Encryption.Decrypt_old(raw));
mod.fread = new Func<string, string>((filepath) => SafeFileRead(filepath)); mod.fread = new Func<string, string>((filepath) => SafeFileRead(filepath));
mod.terminal = new Action<string>((command) => mod.terminal = new Action<string>((command) =>
{ {