Ejemplo n.º 1
0
 /// <summary>
 /// Creates a DLC file from the given File list
 /// </summary>
 /// <param name="FileLinks">List of Files</param>
 /// <param name="Header">Custom DLC Header</param>
 /// <param name="PackageName">Package Name</param>
 /// <param name="Comment">Package Comment</param>
 /// <returns>DLC string</returns>
 public static string CreateDlc(IEnumerable <DlcFile> FileLinks, DlcHeader Header, string PackageName, string Comment)
 {
     if (FileLinks.Count() > 0)
     {
         var XML       = BuildXML(FileLinks, Header, PackageName, Comment);
         var RealKey   = RandomKey(8);
         var FakeKey   = SetKey(RealKey);
         var Encrypted = Tools.B64(AesEncrypt(Tools.ASC(Tools.B64(Tools.ASC(XML))), Tools.ASC(Tools.B2S(RealKey)), Tools.ASC(Tools.B2S(RealKey))));
         return(Encrypted + FakeKey);
     }
     return(null);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Builds
        /// </summary>
        /// <param name="FileLinks">List of Files</param>
        /// <param name="Header">DLC Header</param>
        /// <param name="PackageName">Package Name</param>
        /// <param name="Comment">Package Comment</param>
        /// <returns>XML string</returns>
        private static string BuildXML(IEnumerable <DlcFile> FileLinks, DlcHeader Header, string PackageName, string Comment)
        {
            if (string.IsNullOrEmpty(PackageName))
            {
                Comment = "unknown";
            }
            if (string.IsNullOrEmpty(Comment))
            {
                Comment = PackageName;
            }
            //Build XML Document
            var d = new XmlDocument();

            d.LoadXml("<dlc><header></header><content><package></package></content></dlc>");

            //XML Generator Info
            var Generator = d.CreateElement("generator");

            Generator.AppendChild(CE(d, "app", Tools.B64(Tools.ASC(Header.Generator.App))));
            Generator.AppendChild(CE(d, "version", Tools.B64(Tools.ASC(Header.Generator.Version))));
            Generator.AppendChild(CE(d, "url", Tools.B64(Tools.ASC(Header.Generator.Url))));

            //Build Header
            d["dlc"]["header"].AppendChild(Generator);
            d["dlc"]["header"].AppendChild(CE(d, "tribute", $"<name>{Tools.B64(Tools.ASC(Header.Tribute.Name))}</name>"));
            d["dlc"]["header"].AppendChild(CE(d, "dlcxmlversion", Tools.ASC(Tools.B64(Header.Version))));

            var P = d["dlc"]["content"]["package"];

            P.SetAttribute("name", Tools.B64(Tools.ASC(PackageName)));
            P.SetAttribute("comment", Tools.B64(Tools.ASC(Comment)));
            P.SetAttribute("passwords", "e30=");
            P.SetAttribute("category", "dmFyaW91cw==");

            foreach (var File in FileLinks)
            {
                var F = d.CreateElement("file");
                F.AppendChild(CE(d, "url", Tools.B64(Tools.ASC(File.URL))));
                F.AppendChild(CE(d, "filename", Tools.B64(Tools.ASC(File.Filename))));
                F.AppendChild(CE(d, "size", Tools.B64(Tools.ASC(File.Size.ToString()))));
                P.AppendChild(F);
            }

            return(d.DocumentElement.OuterXml);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Reads the Header of the DLC file
 /// </summary>
 /// <param name="XmlHeader">XML "header" Node</param>
 private void ReadHeader(XmlNode XmlHeader)
 {
     Header = new DlcHeader(XmlHeader);
 }