示例#1
0
        /// <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())));
        }
示例#2
0
 public void SetKey(string key)
 {
     if (string.IsNullOrEmpty(key))
     {
         encryptionEnabled = false;
     }
     else
     {
         if (!obtainedKey)
         {
             crypt       = new Encryption(key);
             obtainedKey = true;
         }
     }
 }
示例#3
0
        /// <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;
                        }
                    }
                }
            }
        }
示例#4
0
 public PacketModifiers()
 {
     crypt = new Security.Encryption();
     crypt.SetKey(DEFAULT_KEY);
 }
示例#5
0
 internal static byte[] EncryptSurface(byte[] imageBytes)
 {
     Security.Encryption encryption = new Security.Encryption(gfxEncryptionKey);
     byte[] encryptedSurface = encryption.EncryptBytes(imageBytes);
     return encryptedSurface;
 }
示例#6
0
文件: PlayerID.cs 项目: pzaps/Server
        /// <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())));
        }
示例#7
0
文件: PlayerID.cs 项目: pzaps/Server
 /// <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;
                 }
             }
         }
     }
 }
示例#8
0
 internal static byte[] EncryptSurface(byte[] imageBytes)
 {
     Security.Encryption encryption = new Security.Encryption(gfxEncryptionKey);
     byte[] encryptedSurface        = encryption.EncryptBytes(imageBytes);
     return(encryptedSurface);
 }
示例#9
0
 public PacketModifiers()
 {
     crypt = new Security.Encryption();
     crypt.SetKey(DEFAULT_KEY);
 }
示例#10
0
 public void SetKey(string key)
 {
     if (string.IsNullOrEmpty(key)) {
         encryptionEnabled = false;
     } else {
         if (!obtainedKey) {
             crypt = new Encryption(key);
             obtainedKey = true;
         }
     }
 }