Exemple #1
0
        /// <summary>
        /// Encrypts a string using a password to generate an alphabet character array.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public string Encrypt(string text, string password)
        {
            var alphabet = new Alphabet().GenerateAlphabetFromPassword(password);

            var manager = new EncryptionManager();

            return manager.Encrypt(text, alphabet);
        }
 public CryptographyService(EncryptionManager encryptionManager, HashManager hashManager)
 {
     this.EncryptionManager = encryptionManager;
     this.HashManager       = hashManager;
 }
 public static RelicManager LoadRelicManager()
 {
     return(EncryptionManager.DeCrypt <RelicManager>(rPath));
 }
 public static void SaveGame(Player p)
 {
     EncryptionManager.EncryptFile(path, p);
 }
Exemple #5
0
 public List <Claim> ValidateUser(string userName, string password, string ipAddress)
 {
     return(this.loginDataAccess.ValidateUser(userName, EncryptionManager.Encrypt(password), ipAddress));
 }
Exemple #6
0
 protected void ImgBtnRegister_Click(object sender, ImageClickEventArgs e)
 {
     if (TxtCaptcha.Text == CaptchaCodeWithImage[0])
     {
         FileManager fm = new FileManager();
         string      ValidationState;
         bool        UploadState;
         if (FUPhoto.HasFile == true)
         {
             fm.MaxFileSizeInMB = 3.0f;
             fm.MyFileUpload    = FUPhoto;
             ValidationState    = fm.ValidateMyFile();
             if (ValidationState == "SUCCESS")
             {
                 UploadState = fm.UploadMyFile("UserPics");
                 if (UploadState == true)
                 {
                     cm.YourCommand = "INSERT into Tbl_profilePic(file_name,folder,user_id,filetype,filesize,isdel) values('" + fm.MyFileName + "','UserPics','" + TxtEmail.Text + "','" + fm.MyFileType + "','" + fm.FileSizeInMB + "','0')";
                     cm.ExecuteInsertOrUpdateOrDelete();
                 }
                 else
                 {
                     Response.Write("<script>alert('Sorry! we are unable to upload picture.');</script>");
                 }
             }
             else
             {
                 Response.Write("<script>alert('" + ValidationState + "');</script>");
             }
         }
         if (FUIDProof.HasFile == true)
         {
             fm.FileSizeInMB     = 5.0f;
             fm.MyFileUpload     = FUIDProof;
             fm.AllowedExtention = new string[] { ".jpg", ".jpeg", ".pdf" };
             ValidationState     = fm.ValidateMyFile();
             if (ValidationState == "SUCCESS")
             {
                 UploadState = fm.UploadMyFile("UserIDProof");
                 if (UploadState == true)
                 {
                     EncryptionManager em            = new EncryptionManager();
                     string            EncryptedPass = em.EncryptMyData(TxtPass.Text);
                     bool Gender;
                     if (RdbMale.Checked == true)
                     {
                         Gender = true;
                     }
                     else
                     {
                         Gender = false;
                     }
                     cm.YourCommand = "INSERT into Tbl_Registration values('" + TxtName.Text + "','" + Gender + "','" + DdlConType.SelectedValue + "','" + TxtAddress.Text + "','" + int.Parse(DdlState.SelectedValue) + "','" + int.Parse(DdlCity.SelectedValue) + "','" + int.Parse(TxtPinCode.Text) + "','" + TxtEmail.Text + "','" + TxtMobNo.Text + "','" + EncryptedPass + "','" + fm.MyFileName + "','" + FUIDProof.FileName + "')";
                     bool b = cm.ExecuteInsertOrUpdateOrDelete();
                     if (b == true)
                     {
                         LoginManager lm = new LoginManager();
                         lm.UserID         = TxtEmail.Text;
                         lm.UserPass       = EncryptedPass;
                         lm.UserStatus     = true;
                         lm.connectionType = "Consumer";
                         lm.LoginCount     = 0;
                         b = lm.SetLoginDetails();
                         if (b == true)
                         {
                             Response.Write("<script>alert('You are registered successfully.');</script>");
                         }
                         else
                         {
                             Response.Write("<script>alert('You are registered successfully.But we are unable to set login details.');</script>");
                         }
                     }
                     else
                     {
                         Response.Write("<script>alert('Unable to register.');</script>");
                     }
                 }
             }
             else
             {
                 Response.Write("<script>alert('" + ValidationState + "');</script>");
             }
         }
         else
         {
             Response.Write("<script>alert('Please upload 1 ID proof.');</script>");
         }
     }
     else
     {
         Response.Write("<script>alert('Invalid Captcha Code.');</script>");
     }
 }
        public void loadSOMData(string connection, string consultaApi)
        {
            Log log = new Log();
            List <autosgrsm_SOM> jsonSOM = null;

            if (consultaApi != "")
            {
                var request = (HttpWebRequest)WebRequest.Create(consultaApi);
                request.Method      = "GET";
                request.ContentType = "application/json";
                request.Accept      = "application/json";

                try
                {
                    using (WebResponse response = request.GetResponse())
                    {
                        using (Stream strReader = response.GetResponseStream())
                        {
                            if (strReader == null)
                            {
                                return;
                            }
                            using (StreamReader objReader = new StreamReader(strReader))
                            {
                                string json             = objReader.ReadToEnd();
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                jsonSOM = js.Deserialize <List <autosgrsm_SOM> >(json);
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    log.insertLogGeneral(3, "Falló Api SOM: " + ex.Message);
                }

                if (jsonSOM.Count > 0)
                {
                    try
                    {
                        foreach (autosgrsm_SOM item in jsonSOM)
                        {
                            item.cadena      = EncryptionManager.Decrypt(connection);
                            item.CREATED     = DateTime.Now;
                            item.STATUS_FLOW = 2;
                            item.insert();

                            log.insertLog(item.CRMNO, item.STATUS_FLOW, "Cargue Tabla SOM");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.insertLogGeneral(4, "Falló Inserción en tabla SOM: " + ex.Message);
                    }
                }
                else
                {
                    log.insertLogGeneral(1, "La consulta SOM no trajo resultados");
                    Console.WriteLine("La consulta SOM no trajo resultados");
                }
            }
        }
Exemple #8
0
    private static string GetLanguage()
    {
        instance.userLanguage = EncryptionManager.GetString("userLanguage");
        if (instance.userLanguage != "")
        {
            return(instance.userLanguage);
        }

        switch (Application.systemLanguage)
        {
        case SystemLanguage.Chinese:
        case SystemLanguage.ChineseSimplified:
            return("Chinese");

        case SystemLanguage.ChineseTraditional:
            return("ChineseTraditional");

        case SystemLanguage.Russian:
        case SystemLanguage.Belarusian:
            return("Russian");   //俄语

        case SystemLanguage.Arabic:
            return("Arabic");   //阿拉伯语

        case SystemLanguage.French:
            return("French");   //法语

        case SystemLanguage.German:
            return("German");   //德语

        case SystemLanguage.Indonesian:
            return("Indonesia");   //印尼语

        case SystemLanguage.Japanese:
            return("Japanese");   //日语

        case SystemLanguage.Korean:
            return("Korean");   //韩语

        case SystemLanguage.Ukrainian:
            return("Ukrainian");   //乌克兰语

        case SystemLanguage.Afrikaans:
        case SystemLanguage.Basque:
        case SystemLanguage.Bulgarian:
        case SystemLanguage.Catalan:
        case SystemLanguage.Czech:
        case SystemLanguage.Danish:
        case SystemLanguage.Dutch:
        case SystemLanguage.English:
        case SystemLanguage.Estonian:
        case SystemLanguage.Faroese:
        case SystemLanguage.Finnish:
        case SystemLanguage.Greek:
        case SystemLanguage.Hebrew:
        case SystemLanguage.Icelandic:
        case SystemLanguage.Italian:
        case SystemLanguage.Latvian:
        case SystemLanguage.Lithuanian:
        case SystemLanguage.Norwegian:
        case SystemLanguage.Polish:
        case SystemLanguage.Portuguese:
        case SystemLanguage.Romanian:
        case SystemLanguage.SerboCroatian:
        case SystemLanguage.Slovak:
        case SystemLanguage.Slovenian:
        case SystemLanguage.Spanish:
        case SystemLanguage.Swedish:
        case SystemLanguage.Thai:
        case SystemLanguage.Turkish:
        case SystemLanguage.Vietnamese:
        case SystemLanguage.Unknown:
            return("English");
        }
        return("English");
    }
 public TestNode(RoutingManager routingManager, TcpConnectionManager connectionManager, DataManager dataManager, EncryptionManager encryptionManager)
 {
     this.routingManager    = routingManager;
     this.connectionManager = connectionManager;
     this.dataManager       = dataManager;
     this.encryptionManager = encryptionManager;
 }
        public ActionResult UserName(User newUser)
        {
            string newEmail = newUser.EmailAddress;
            string newName  = newUser.Name;

            newUser = (User)Session["user"];
            if (newUser == null)
            {
                return(View("User", "ChangeUser"));
            }
            string salt = EncryptionManager.PasswordSalt;

            if (newEmail != null && newName != null)
            {
                User Users = new User
                {
                    Id           = newUser.Id,
                    Name         = newName,
                    EmailAddress = newEmail,
                    Salt         = salt,
                    HashPassword = EncryptionManager.EncodePassword("abc123", salt),
                    IsAdmin      = 0,
                    Status       = 0
                };
                bool result = UserPersistence.UpdateUser(Users);
                if (result)
                {
                    ViewBag.message = "User Updated";
                }
                else
                {
                    ViewBag.message = "That user could not be Updated";
                }
            }
            else if (newEmail != null && newName == null)
            {
                User Users = new User
                {
                    Id           = newUser.Id,
                    Name         = newUser.Name,
                    EmailAddress = newEmail,
                    Salt         = salt,
                    HashPassword = EncryptionManager.EncodePassword("abc123", salt),
                    IsAdmin      = 0,
                    Status       = 0
                };
                bool result = UserPersistence.UpdateUser(Users);
                if (result)
                {
                    ViewBag.message = "User Updated";
                }
                else
                {
                    ViewBag.message = "That user could not be Updated";
                }
            }
            else
            {
                User Users = new User
                {
                    Id           = newUser.Id,
                    Name         = newName,
                    EmailAddress = newUser.EmailAddress,
                    Salt         = salt,
                    HashPassword = EncryptionManager.EncodePassword("abc123", salt),
                    IsAdmin      = 0,
                    Status       = 0
                };

                bool result = UserPersistence.UpdateUser(Users);
                if (result)
                {
                    ViewBag.message = "User Updated";
                }
                else
                {
                    ViewBag.message = "That user could not be Updated";
                }
            }
            return(View(newUser));
        }
        public void AESEncrypt_ReturnsCorrectCipher_AnyTextAndKeyGiven(string plainText, string key, string expResult)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.AreEqual(expResult, instance.AESEncrypt(key, plainText));
        }
        public void CalculateHMAC_ReturnsCorrectHash_AnyTextAndKeyGiven(string text, string key, string expResult)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.AreEqual(expResult, instance.CalculateHMAC(text, key));
        }
        public void CalculateHMAC_ThrowsException_EmptyStringOrKeyGiven(string text, string key)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.Throws <ArgumentException>(() => instance.CalculateHMAC(text, key));
        }
        public void CalculateSHA512_ReturnsCorrectHash_AnyTextGiven(string text, string expResult)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.AreEqual(expResult, instance.CalculateSHA512(text));
        }
        public void AESDecrypt_ThrowsException_IncorrectCipherLength(string cipherText, string key)
        {
            EncryptionManager instance = new EncryptionManager();

            Assert.Throws <ArgumentException>(() => instance.AESDecrypt(key, cipherText));
        }
        protected override PlainText GetText()
        {
            var result = new PlainText();
            var txt    = new StringBuilder();

            var encryptedData = System.IO.File.ReadAllBytes(Path);
            var data          = EncryptionManager.DecryptData(encryptedData);

            using (var ms = new MemoryStream(data))
                using (var input = new ExtendedBinaryReader(ms))
                {
                    var messageCount = input.ReadUInt16();
                    var dummy        = input.ReadUInt16();

                    var messageOffset = new uint[messageCount];
                    var messageSize   = new uint[messageCount];
                    for (var i = 0; i < messageCount; i++)
                    {
                        messageOffset[i] = input.ReadUInt32();
                    }

                    for (var i = 0; i < messageCount - 1; i++)
                    {
                        messageSize[i] = messageOffset[i + 1] - messageOffset[i];
                    }

                    messageSize[messageCount - 1] = (uint)(data.Length - messageOffset[messageCount - 1]);

                    for (var i = 0; i < messageCount; i++)
                    {
                        input.Seek(messageOffset[i], SeekOrigin.Begin);
                        if (i > 0)
                        {
                            txt.AppendLine();
                        }

                        txt.AppendLine(messageOffset[i] < data.Length ? $"StartMessage({input.Position});" : $"StartMessageExtra({input.Position});");

                        while (input.Position < input.Length && input.Position - messageOffset[i] < messageSize[i])
                        {
                            var offset = input.Position;
                            var type   = input.ReadUInt16();

                            if (type < 128)
                            {
                                var op = GameOps[type];

                                var args = new string[op.ParamCount];
                                for (var j = 0; j < op.ParamCount; j++)
                                {
                                    args[j] = string.Concat(input.ReadUInt16().ToString());
                                }

                                txt.AppendLine($"{op.Name}({string.Join(", ", args)});");
                            }
                            else
                            {
                                var sb = new StringBuilder();
                                while (input.Position < input.Length && type >= 128)
                                {
                                    var c = type - 128;
                                    sb.Append((char)c);
                                    type = input.ReadUInt16();
                                }

                                var value = sb.ToString().ToHalfWidthChars();

                                var text = string.Concat("Text(\"", value, "\");");

                                txt.AppendLine(text);

                                if (input.Position < input.Length)
                                {
                                    input.Seek(-2, SeekOrigin.Current);
                                }
                            }
                        }
                    }
                }

            result.Text             = txt.ToString();
            result.Translation      = txt.ToString();
            result.Loaded           = txt.ToString();
            result.PropertyChanged += SubtitlePropertyChanged;

            LoadChanges(result);

            return(result);
        }
Exemple #17
0
        private byte[] BuildPdf()
        {
            AlertData pageData;

            baseApplicationUrl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + ResolveUrl("~/");

            if (Request.QueryString["pcid"] != null)
            {
                string query = Request.QueryString["pcid"];
                query = query.Replace(" ", "+");
                string pcid = EncryptionManager.Decrypt(query);
                pageData = PopulateByProblemCaseId(Convert.ToDecimal(pcid));
            }
            else if (Request.QueryString["iid"] != null)
            {
                string query = Request.QueryString["iid"];
                query = query.Replace(" ", "+");
                string iid = EncryptionManager.Decrypt(query);
                pageData = PopulateByIncidentId(Convert.ToDecimal(iid));
            }
            else
            {
                pageData = PopulateAlertDataTest();
            }

            string customerLogo = "";

            customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogoLarge"].ToString();
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = System.Configuration.ConfigurationManager.AppSettings["CustomerLogo"].ToString();
            }
            if (string.IsNullOrEmpty(customerLogo))
            {
                customerLogo = "MetricsoftLogo.png";
            }

            string logoUrl = baseApplicationUrl + "images/company/" + customerLogo;

            Font textFont   = GetTextFont();
            Font headerFont = GetHeaderFont();

            BaseColor darkGrayColor  = new BaseColor(0.25f, 0.25f, 0.25f);
            BaseColor lightGrayColor = new BaseColor(0.5f, 0.5f, 0.5f);
            BaseColor whiteColor     = new BaseColor(1.0f, 1.0f, 1.0f);
            BaseColor blackColor     = new BaseColor(0.0f, 0.0f, 0.0f);

            // Create new PDF document
            Document document = new Document(PageSize.A4, 35f, 35f, 35f, 35f);

            using (MemoryStream output = new MemoryStream())
            {
                PdfWriter.GetInstance(document, output);

                document.Open();

                //
                // Table 1 - Header
                //

                var table1 = new PdfPTable(new float[] { 162f, 378f });
                table1.TotalWidth         = 540f;
                table1.LockedWidth        = true;
                table1.DefaultCell.Border = 0;
                table1.DefaultCell.HorizontalAlignment = PdfPCell.ALIGN_LEFT;
                table1.DefaultCell.VerticalAlignment   = PdfPCell.ALIGN_MIDDLE;
                table1.SpacingAfter = 12f;

                iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(logoUrl);
                img.ScaleToFit(162f, 81f);
                var imgCell = new PdfPCell()
                {
                    Border = 0
                };
                imgCell.AddElement(img);
                table1.AddCell(imgCell);

                var hdrFont = new Font(headerFont.BaseFont, 38, 0, darkGrayColor);
                table1.AddCell(new PdfPCell(new Phrase("EH&S INCIDENT ALERT", hdrFont))
                {
                    HorizontalAlignment = Element.ALIGN_RIGHT,
                    VerticalAlignment   = Element.ALIGN_MIDDLE,
                    Border = 0
                });


                //
                // Table 2 - Information block
                //

                var infoFont = new Font(headerFont.BaseFont, 14, 0, whiteColor);

                var table2 = new PdfPTable(new float[] { 240f, 300f });
                table2.TotalWidth   = 540f;
                table2.LockedWidth  = true;
                table2.SpacingAfter = 12f;

                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentDateTime, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentNumber, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, HorizontalAlignment = Element.ALIGN_RIGHT, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentLocation, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, PaddingTop = 0, Border = 0
                });
                table2.AddCell(new PdfPCell(new Phrase(pageData.incidentType, infoFont))
                {
                    BackgroundColor = darkGrayColor, Padding = 10f, PaddingTop = 0, HorizontalAlignment = Element.ALIGN_RIGHT, Border = 0
                });
                table2.Complete = true;

                //
                // Table 3 - Description and details
                //

                var detailHdrFont = new Font(headerFont.BaseFont, 14, 0, lightGrayColor);
                var detailTxtFont = new Font(textFont.BaseFont, 12, 0, blackColor);

                var table3 = new PdfPTable(new float[] { 135f, 405f });
                table3.TotalWidth  = 540f;
                table3.LockedWidth = true;
                table3.DefaultCell.SetLeading(40f, 40f);
                table3.SpacingAfter = 12f;
                PdfPCell cell;

                cell = new PdfPCell(new Paragraph("DESCRIPTION", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Phrase(pageData.incidentDescription, detailTxtFont))
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("ROOT CAUSE", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentRootCause)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("CONTAINMENT", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentContainment)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell(new Paragraph("CORRECTIVE ACTIONS", detailHdrFont))
                {
                    Padding = 12f, Border = 0, HorizontalAlignment = Element.ALIGN_RIGHT
                };
                cell.SetLeading(17f, 0f);
                table3.AddCell(cell);

                cell = new PdfPCell()
                {
                    Padding = 8f, PaddingBottom = 12f, Border = 0
                };
                foreach (var lineItem in pageData.incidentCorrectiveActions)
                {
                    cell.AddElement(new Paragraph(lineItem, detailTxtFont));
                }
                cell.SetLeading(20f, 0f);
                table3.AddCell(cell);


                //
                // Table 4 - Photos
                //

                var table4 = new PdfPTable(new float[] { 180f, 180f, 180f });
                table4.TotalWidth  = 540f;
                table4.LockedWidth = true;

                if (pageData.photoData != null && pageData.photoData.Count() > 0)
                {
                    table4.AddCell(new PdfPCell(new Phrase("Photos", infoFont))
                    {
                        BackgroundColor = darkGrayColor, Padding = 10f, Border = 0, Colspan = 3
                    });

                    var captionFont = new Font(textFont.BaseFont, 11, 0, darkGrayColor);

                    int i = 0;
                    for (i = 0; i < pageData.photoData.Count; i++)
                    {
                        var photoCell = new PdfPCell()
                        {
                            PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                        };

                        iTextSharp.text.Image photo = iTextSharp.text.Image.GetInstance(pageData.photoData[i]);
                        photo.ScaleToFit(176f, 132f);
                        photoCell.AddElement(photo);

                        photoCell.AddElement(new Phrase(pageData.photoCaptions[i], captionFont));

                        table4.AddCell(photoCell);
                    }
                    // pad remaining cells in row or else table will be corrupt
                    int currentCol = i % 3;
                    for (int j = 0; j < 3 - currentCol; j++)
                    {
                        table4.AddCell(new PdfPCell()
                        {
                            PaddingLeft = 0, PaddingRight = 4, PaddingTop = 8, PaddingBottom = 8, Border = 0
                        });
                    }
                }

                document.Add(table1);
                document.Add(table2);
                document.Add(table3);
                document.Add(table4);

                document.Close();

                return(output.ToArray());
            }
        }
        public override void Rebuild(string outputFolder)
        {
            var outputPath = System.IO.Path.Combine(outputFolder, RelativePath);

            Directory.CreateDirectory(System.IO.Path.GetDirectoryName(outputPath));

            var subtitles = GetText();

            byte[] outputData;
            var    outputMessageOffset      = new List <uint>();
            var    outputMessageExtraOffset = new List <uint>();

            using (var msOutput = new MemoryStream())
                using (var output = new ExtendedBinaryWriter(msOutput, FileEncoding))
                {
                    var outputOffset = 0u;
                    var lines        = subtitles.Translation.Split(new [] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var line in lines)
                    {
                        var pattern1 = "(?<op>\\w+)\\((?<params>.*)\\)\\;";
                        var pattern2 = "(?<op>\\w+)\\(\"(?<params>.*)\"\\)\\;";

                        var pattern = Regex.IsMatch(line, pattern2) ? pattern2 : pattern1;
                        var matches = Regex.Matches(line, pattern);
                        var opName  = matches[0].Groups["op"].Value;
                        var opParam = matches[0].Groups["params"].Value;

                        if (opName != "Text")
                        {
                            if (opName == "StartMessage")
                            {
                                outputMessageOffset.Add(outputOffset);
                                continue;
                            }

                            if (opName == "StartMessageExtra")
                            {
                                outputMessageExtraOffset.Add(uint.Parse(opParam));
                                continue;
                            }

                            var op = GameOps.FirstOrDefault(x => x.Name == opName);
                            if (op != null)
                            {
                                output.Write(op.Code);
                                var split = opParam.Split(',');
                                foreach (var s in split)
                                {
                                    if (!string.IsNullOrWhiteSpace(s))
                                    {
                                        output.Write(ushort.Parse(s.Trim()));
                                    }
                                }
                            }
                        }
                        else
                        {
                            var outputText = opParam.ToFullWidthChars();
                            foreach (var chr in outputText)
                            {
                                var c = (ushort)(chr + 128);
                                output.Write(c);
                            }
                        }

                        outputOffset = (uint)output.Position;
                    }

                    outputData = msOutput.ToArray();
                }

            byte[] unencryptedFile;
            using (var msOutput = new MemoryStream())
                using (var output = new ExtendedBinaryWriter(msOutput, FileEncoding))
                {
                    var totalMessageCount = outputMessageOffset.Count + outputMessageExtraOffset.Count;
                    output.Write((ushort)totalMessageCount);
                    output.Write((ushort)0);
                    foreach (var offset in outputMessageOffset)
                    {
                        output.Write((uint)(offset + 4 + totalMessageCount * 4));
                    }

                    foreach (var offset in outputMessageExtraOffset)
                    {
                        output.Write(offset);
                    }
                    output.Write(outputData);

                    unencryptedFile = msOutput.ToArray();
                }

            var encryptedFile = EncryptionManager.EncryptData(unencryptedFile);

            System.IO.File.WriteAllBytes(outputPath, encryptedFile);
        }
Exemple #19
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            try
            {
                if (tbFromMail.Text == "")
                {
                    throw new Exception("From E-Mail is Blank ! Please Fill.");
                }

                if (tbFromMailPass.Text == "")
                {
                    throw new Exception("From Mail Password is Blank ! Please Fill.");
                }

                if (tbSmtpHost.Text == "")
                {
                    throw new Exception("From Smtp Host is Blank ! Please Fill.");
                }



                #region SaveEMailSettingsToXML
                DataTable dtEmail = new DataTable("dtEMail");
                dtEmail.Columns.Add("FromEMail");
                dtEmail.Columns.Add("Password");
                dtEmail.Columns.Add("SmtpHost");
                dtEmail.Columns.Add("SmtpPort");
                dtEmail.Columns.Add("EnableSSL");

                if (!File.Exists("dtEMail.xsd"))
                {
                    dtEmail.WriteXmlSchema("dtEMail.xsd");
                }

                DataRow dr = dtEmail.NewRow();

                dr["FromEMail"] = tbFromMail.Text;
                dr["Password"]  = EncryptionManager.Encrypt(tbFromMailPass.Text);
                dr["SmtpHost"]  = tbSmtpHost.Text;
                dr["SmtpPort"]  = spnSmtpPort.Value.ToString();
                if (cbSSL.Checked == true)
                {
                    dr["EnableSSL"] = "1";
                }
                else
                {
                    dr["EnableSSL"] = "0";
                }


                dtEmail.Rows.Add(dr);

                dtEmail.WriteXml("dtEMail.xml");
                #endregion



                saveEMail(tbFromMail.Text, tbFromMailPass.Text, tbSmtpHost.Text, Convert.ToInt32(spnSmtpPort.Value), Convert.ToBoolean(cbSSL.CheckState));
                Close();
            }
            catch (Exception ex)
            {
                MessageManager.ShowErrorMessage(ex.Message);
            }
        }
Exemple #20
0
 public static void SetDouble(string key, double val)
 {
     PlayerPrefs.SetString(EncryptionManager.GetHash(key), EncryptionManager.Encrypt(val.ToString()));
 }
        public void loadSIGRESData(string connection, string consultaApi, CAIs CAI)
        {
            Log log = new Log();
            List <autosgrsm_SIGRES> jsonSigres = null;

            if (consultaApi != "")
            {
                var request = (HttpWebRequest)WebRequest.Create(consultaApi + CAI.CAI);
                request.Method      = "GET";
                request.ContentType = "application/json";
                request.Accept      = "application/json";

                try
                {
                    using (WebResponse response = request.GetResponse())
                    {
                        using (Stream strReader = response.GetResponseStream())
                        {
                            if (strReader == null)
                            {
                                return;
                            }
                            using (StreamReader objReader = new StreamReader(strReader))
                            {
                                string json             = objReader.ReadToEnd();
                                JavaScriptSerializer js = new JavaScriptSerializer();
                                jsonSigres = js.Deserialize <List <autosgrsm_SIGRES> >(json);
                            }
                        }
                    }
                }
                catch (WebException ex)
                {
                    log.insertLogGeneral(3, "Falló Api Sigres: " + ex.Message);
                }

                if (jsonSigres.Count > 0)
                {
                    try
                    {
                        foreach (autosgrsm_SIGRES item in jsonSigres)
                        {
                            autosgrsm_SOM som = getSomDataByCRMNO(connection, CAI.CRMNO);
                            som.cadena      = EncryptionManager.Decrypt(connection);
                            som.STATUS_CAI  = item.ESTADO;
                            som.STATUS_FLOW = 5;
                            som.queryUpdate = "WHERE CRMNO = @CRMNO";
                            dicParameter    = new Dictionary <string, string>();
                            dicParameter.Add("@CRMNO", CAI.CRMNO);
                            som.update(dicParameter);

                            log.insertLog(CAI.CRMNO, som.STATUS_FLOW, "Actualización del Estado CAI");
                        }
                    }
                    catch (Exception ex)
                    {
                        log.insertLogGeneral(4, "Falló Actualziación en tabla SOM (Estado CAI): " + ex.Message);
                    }
                }
                else
                {
                    log.insertLog(CAI.CRMNO, 3, "No se encontró data para el CAI: " + CAI.CAI);
                    Console.WriteLine("No se encontró data para el CAI: " + CAI.CAI);
                }
            }
        }
Exemple #22
0
 public static void SetString(string key, string val)
 {
     PlayerPrefs.SetString(EncryptionManager.GetHash(key), EncryptionManager.Encrypt(val));
 }
Exemple #23
0
        public override void SetDefaultContentHeaders(Type type, HttpContentHeaders headers, MediaTypeHeaderValue mediaType)
        {
            headers.Add(RestfulServiceConstants.RqModelTypeHeaderKey, EncryptionManager.Encrypt(type.AssemblyQualifiedName));

            base.SetDefaultContentHeaders(type, headers, mediaType);
        }
Exemple #24
0
    public static bool HasKey(string key)
    {
        string hash = EncryptionManager.GetHash(key);

        return(PlayerPrefs.HasKey(hash));
    }
Exemple #25
0
 internal SocketClient(Uri uri, EncryptionManager encryptionManager, ITcpSocketClient socketClient)
     : this(uri, encryptionManager, null, socketClient)
 {
 }
Exemple #26
0
    public static void DeleteKey(string key)
    {
        string hash = EncryptionManager.GetHash(key);

        PlayerPrefs.DeleteKey(hash);
    }
 public static void SaveRelicManager(RelicManager rm)
 {
     EncryptionManager.EncryptFile(rPath, rm);
 }
Exemple #28
0
        /*
         * Recreate and reinitialize the database.
         * The return value is true iff the initialization succeeds.
         */
        public bool Initialize()
        {
            bool openResult;

            if (File.Exists(databaseFile) && new FileInfo(databaseFile).Length > 10)
            {
                openResult = Open();
                return(openResult);
            }

            bool success = true;

            Close();

            try
            {
                SQLiteConnection.CreateFile(databaseFile);
            }
            catch (IOException e)
            {
                success = false;
            }

            openResult = Open();
            if (success & openResult)
            {
                string salt;
                string sql = "CREATE TABLE user (UserId VARCHAR(50), Name VARCHAR(50),Salt VARCHAR(50), HashedPassword VARCHAR(50),Email VARCHAR(50),IsAdmin BIT,Status VARCHAR(1),Gender VARCHAR(6),BirthDate VARCHAR(10), Location VARCHAR(30), PRIMARY KEY(UserId));";
                DoCommand(sql);
                sql = "CREATE TABLE car (carId INTEGER, Brand VARCHAR(50), Model VARCHAR(50),Owner VARCHAR(50),YearOfProduction INTEGER,KM INT,Url VARCHAR(200),TransmissionType VARCHAR(15), Fuel VARCHAR(15),TopSpeed INT, Acceleration Float,UrbanConsumption Float, WheelDrive VARCHAR(20), PRIMARY KEY(carId),FOREIGN KEY (Owner) references user(UserId));";
                DoCommand(sql);
                sql = "CREATE TABLE comment (CommentId INTEGER, carId INTEGER,UserId VARCHAR(50), Text VARCHAR(300),FOREIGN KEY (carId) references car(carId),PRIMARY KEY(CommentId),FOREIGN KEY (UserId) references user(UserId));";
                DoCommand(sql);
                sql = "CREATE TABLE favourites (UserId VARCHAR(12), carId INTEGER,FOREIGN KEY (carId) references car(carId),FOREIGN KEY (UserId) references user(UserId));";
                DoCommand(sql);

                salt = User.CreateSalt();
                sql  = "insert into user (UserId, Name,Salt, HashedPassword,Email,IsAdmin,Status,Gender,BirthDate,Location) values ('"
                       + "crysispeed" + "', '"
                       + "Caglar" + "', '"
                       + salt + "', '"
                       + EncryptionManager.EncodePassword("123456", salt) + "', '"
                       + "*****@*****.**" + "',"
                       + "1" + ", '"
                       + "A" + "','"
                       + "Male" + "', '"
                       + "1995-08-26" + "', '"
                       + "Ankara" + "');";
                DoCommand(sql);
                salt = User.CreateSalt();
                sql  = "insert into user (UserId, Name,Salt, HashedPassword,Email,IsAdmin,Status,Gender,BirthDate,Location) values ('"
                       + "gurko32" + "', '"
                       + "Gurkan" + "', '"
                       + salt + "', '"
                       + EncryptionManager.EncodePassword("123456", salt) + "', '"
                       + "*****@*****.**" + "',"
                       + "1" + ", '"
                       + "A" + "', '"
                       + "Male" + "', '"
                       + "1996-10-16" + "', '"
                       + "Ankara" + "');";
                DoCommand(sql);
                UserPersistence.PrintAllUsers();
            }

            return(success);
        }
Exemple #29
0
 public void setStatus(int status)
 {
     EncryptionManager.SetInt(saveKey, status);
     EncryptionManager.Save();
     data.SetNumberValue("musicStatus", status);
 }
Exemple #30
0
 public void RemoveAds()
 {
     DataManager.Instance.getData("RemoveAD").SetIntValue("popAdStatus", 1);
     EncryptionManager.SetInt("RemoveAD", 1);
     EncryptionManager.Save();
 }
 public string Encrypt(string serializedObject, string salt)
 {
     return(EncryptionManager.Encrypt(serializedObject, salt));
 }
Exemple #32
0
        /// <summary>
        /// Encrypts a string using an alphabet character array.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="alphabet"></param>
        /// <returns></returns>
        public string Encrypt(string text, char[] alphabet)
        {
            var manager = new EncryptionManager();

            return manager.Encrypt(text, alphabet);
        }