diff --git a/source/WindowsFormsApplication1/API.cs b/source/WindowsFormsApplication1/API.cs index 9c8c69c..f952a18 100644 --- a/source/WindowsFormsApplication1/API.cs +++ b/source/WindowsFormsApplication1/API.cs @@ -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); + } + } + } + } + } + } + + /// /// Decrypts an encrypted string. /// diff --git a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs index 21acb3c..88a51a3 100644 --- a/source/WindowsFormsApplication1/Engine/Lua_Interp.cs +++ b/source/WindowsFormsApplication1/Engine/Lua_Interp.cs @@ -399,8 +399,8 @@ public void RegisterCore() mod.get_codepoints = new Func(() => GetCP()); mod.buy_upgrade = new Func((id) => BuyUPG(id)); mod.time = new Func(() => API.GetTime()); - mod.encrypt = new Func((raw) => API.Encryption.Encrypt(raw)); - mod.decrypt = new Func((raw) => API.Encryption.Decrypt(raw)); + mod.encrypt = new Func((raw) => API.Encryption.Encrypt_old(raw)); + mod.decrypt = new Func((raw) => API.Encryption.Decrypt_old(raw)); mod.fread = new Func((filepath) => SafeFileRead(filepath)); mod.terminal = new Action((command) => {