/// <summary> /// Saves the ID settings to the configuration file /// </summary> public static void SaveIDInfo() { StringBuilder output = new StringBuilder(); // Write a new xml document to the 'output' StringBuilder using (XmlWriter writer = XmlWriter.Create(output, Settings.XmlWriterSettings)) { writer.WriteStartDocument(); // Write the root node writer.WriteStartElement("ID"); // Write the 'PlayerID' node writer.WriteStartElement("PlayerID"); writer.WriteElementString("LastPlayerStringID", lastPlayerStringID); writer.WriteElementString("LastPlayerIntID", lastPlayerIntID.ToString()); // Close the 'PlayerID' node writer.WriteEndElement(); // Write the 'AccountID' node writer.WriteStartElement("AccountID"); writer.WriteElementString("LastAccountStringID", lastAccountStringID); writer.WriteElementString("LastAccountIntID", lastAccountIntID.ToString()); // Close the 'AccountID' node writer.WriteEndElement(); // Close the root node writer.WriteEndElement(); writer.WriteEndDocument(); } // Encrypt the xml string and write the encrypted value to the file Security.Encryption crypt = new Security.Encryption(ENCRYPTION_KEY); System.IO.File.WriteAllBytes(Path.Combine(IO.Paths.DataFolder, "playerid.dat"), crypt.EncryptBytes(System.Text.Encoding.Unicode.GetBytes(output.ToString()))); }
public void SetKey(string key) { if (string.IsNullOrEmpty(key)) { encryptionEnabled = false; } else { if (!obtainedKey) { crypt = new Encryption(key); obtainedKey = true; } } }
/// <summary> /// Loads the ID settings from the configuration file /// </summary> public static void LoadIDInfo() { // Check if the configuration file exists, if not, create it if (IO.IO.FileExists(Path.Combine(IO.Paths.DataFolder, "playerid.dat")) == false) { SaveIDInfo(); } // Decrypt the configuration file into a string Security.Encryption crypt = new Security.Encryption(ENCRYPTION_KEY); string xmlData = System.Text.Encoding.Unicode.GetString(crypt.DecryptBytes(System.IO.File.ReadAllBytes(Path.Combine(IO.Paths.DataFolder, "playerid.dat")))); using (XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlData))) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "LastPlayerStringID": { lastPlayerStringID = reader.ReadString(); } break; case "LastPlayerIntID": { lastPlayerIntID = reader.ReadString().ToUlng(); } break; case "LastAccountStringID": { lastAccountStringID = reader.ReadString(); } break; case "LastAccountIntID": { lastAccountIntID = reader.ReadString().ToUlng(); } break; } } } } }
public PacketModifiers() { crypt = new Security.Encryption(); crypt.SetKey(DEFAULT_KEY); }
internal static byte[] EncryptSurface(byte[] imageBytes) { Security.Encryption encryption = new Security.Encryption(gfxEncryptionKey); byte[] encryptedSurface = encryption.EncryptBytes(imageBytes); return encryptedSurface; }
/// <summary> /// Saves the ID settings to the configuration file /// </summary> public static void SaveIDInfo() { StringBuilder output = new StringBuilder(); // Write a new xml document to the 'output' StringBuilder using (XmlWriter writer = XmlWriter.Create(output, Settings.XmlWriterSettings)) { writer.WriteStartDocument(); // Write the root node writer.WriteStartElement("ID"); // Write the 'PlayerID' node writer.WriteStartElement("PlayerID"); writer.WriteElementString("LastPlayerStringID", lastPlayerStringID); writer.WriteElementString("LastPlayerIntID", lastPlayerIntID.ToString()); // Close the 'PlayerID' node writer.WriteEndElement(); // Write the 'AccountID' node writer.WriteStartElement("AccountID"); writer.WriteElementString("LastAccountStringID", lastAccountStringID); writer.WriteElementString("LastAccountIntID", lastAccountIntID.ToString()); // Close the 'AccountID' node writer.WriteEndElement(); // Close the root node writer.WriteEndElement(); writer.WriteEndDocument(); } // Encrypt the xml string and write the encrypted value to the file Security.Encryption crypt = new Security.Encryption(ENCRYPTION_KEY); System.IO.File.WriteAllBytes(IO.Paths.DataFolder + "playerid.dat", crypt.EncryptBytes(System.Text.Encoding.Unicode.GetBytes(output.ToString()))); }
/// <summary> /// Loads the ID settings from the configuration file /// </summary> public static void LoadIDInfo() { // Check if the configuration file exists, if not, create it if (IO.IO.FileExists(IO.Paths.DataFolder + "playerid.dat") == false) { SaveIDInfo(); } // Decrypt the configuration file into a string Security.Encryption crypt = new Security.Encryption(ENCRYPTION_KEY); string xmlData = System.Text.Encoding.Unicode.GetString(crypt.DecryptBytes(System.IO.File.ReadAllBytes(IO.Paths.DataFolder + "playerid.dat"))); using (XmlTextReader reader = new XmlTextReader(new System.IO.StringReader(xmlData))) { while (reader.Read()) { if (reader.IsStartElement()) { switch (reader.Name) { case "LastPlayerStringID": { lastPlayerStringID = reader.ReadString(); } break; case "LastPlayerIntID": { lastPlayerIntID = reader.ReadString().ToUlng(); } break; case "LastAccountStringID": { lastAccountStringID = reader.ReadString(); } break; case "LastAccountIntID": { lastAccountIntID = reader.ReadString().ToUlng(); } break; } } } } }
internal static byte[] EncryptSurface(byte[] imageBytes) { Security.Encryption encryption = new Security.Encryption(gfxEncryptionKey); byte[] encryptedSurface = encryption.EncryptBytes(imageBytes); return(encryptedSurface); }