private void btnFileSave1_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(tbPath.Text)) { WarningNotice.InputString(); return; } if (!File.Exists(tbPath.Text)) { WarningNotice.NotFound(); return; } if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } if (DialogResult.OK == sfdFile.ShowDialog()) { FileInfo file = new FileInfo(tbPath.Text); FileInfo result = new FileInfo(sfdFile.FileName); fileSize = file.Length; Task.Factory.StartNew(() => { ControlEnable(this.Controls, false); TripleDESEncryption.Encrypt(file, result, tbPassword.Text, tbIV.Text); this.Invoke(new Action(() => WarningNotice.Save())); ControlEnable(this.Controls, true); }); } sfdFile.FileName = ""; }
public string DecryptPasswordResetToken(string token) { using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { token = System.Web.HttpUtility.UrlDecode(decrypter.Decrypt(token)); } return(token); }
private void btnEncrypt_Click(object sender, EventArgs e) { if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } tbToText.Text = TripleDESEncryption.Encrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); }
public string GeneratePasswordResetToken(string token) { using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { token = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(token)); } //var linkurl = "{0}/Account/ResetPassword?token={1}"; //string domainName = System.Web.HttpContext.Current.Request.Url.Host; //return string.Format(linkurl, domainName, token); return(token); }
//public byte[] GenerateUserExcelBySearchCriteria(UserSearchCriteriaDTO searchCriteria, PagingInformation pageInfo) //{ // //For excel export, we need to export all records. // //So set the pageindex and pagesize to -1 // pageInfo.StartIndex = -1; // pageInfo.PageSize = -1; // var list = GetUserBySearchCriteria(searchCriteria, pageInfo); // //Get excel export list // var excelList = mapper.Map<IList<BusinessRuleExportExcelModel>>(list); // return excelList.ToExcelContent(); //} public bool RedirectUseToken(string username, string password, string timestamp, out string conciergeID) { conciergeID = string.Empty; if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(timestamp)) { return(false); } var decrypted_username = string.Empty; var decrypted_password = string.Empty; var decrypted_timestamp = string.Empty; using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { try { decrypted_username = decrypter.Decrypt(username); decrypted_password = decrypter.Decrypt(password); decrypted_timestamp = decrypter.Decrypt(timestamp); } catch (FormatException fe) { return(false); } catch (Exception e) { return(false); } } DateTime datetime = DateTime.Parse(decrypted_timestamp); if (DateTime.Compare(datetime.AddDays(20), DateTime.Now) < 0) { return(false); } //Encode the password user input var encodedPassword = SimpleTextEncodeHelper.EncodeText(decrypted_password); var userid = decrypted_username; //Retrieve user information from concierge login table var user = conciergeLoginloginRepo.Get(x => x.ConciergeID == userid && x.password == encodedPassword); if (user != null) { conciergeID = user.ConciergeID; return(true); } return(false); }
private void btnDecrypt_Click(object sender, EventArgs e) { if (tbIV.Text.Length != 8) { WarningNotice.IVLength(8); return; } try { tbToText.Text = TripleDESEncryption.Decrypt(tbFromText.Text, tbPassword.Text, tbIV.Text); } catch (Exception) { WarningNotice.WrongKey(); } }
public string GenerateRedirectUrlToken(string username, string password, DateTime dt) { string encrypted_username = string.Empty; string encrypted_password = string.Empty; string encrypted_timestamp = string.Empty; using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { encrypted_username = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(username)); encrypted_password = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(password)); encrypted_timestamp = System.Web.HttpUtility.UrlEncode(encrypter.Encrypt(dt.ToString())); } var linkurl = "{0}/Account/SSORedirectUrl?username={1}&password={2}×tamp={3}"; string domainName = System.Web.HttpContext.Current.Request.Url.Host; return(string.Format(linkurl, domainName, encrypted_username, encrypted_password, encrypted_timestamp)); //return token; }
public bool LoginUseToken(string token, out LoginTokenDTO loginToken) { loginToken = new LoginTokenDTO(); if (string.IsNullOrEmpty(token)) { return(false); } var decryptedString = string.Empty; using (var decrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { decryptedString = decrypter.Decrypt(token); } var paramsFromUrl = StringHelper.SplitString(decryptedString, "&") .Select(p => { var m = p.Split('='); return(new { key = m[0], value = m[1] }); }) .ToDictionary(x => x.key, x => x.value); //Encode the password user input var encodedPassword = SimpleTextEncodeHelper.EncodeText(paramsFromUrl["pwd"]); var username = paramsFromUrl["uid"]; //Retrieve user information from concierge login table var user = conciergeLoginloginRepo.Get(x => x.ConciergeID == username && x.password == encodedPassword); if (user != null) { string arrivalDate, status; paramsFromUrl.TryGetValue("arrivaldate", out arrivalDate); paramsFromUrl.TryGetValue("status", out status); //Set Info loginToken.UserName = user.ConciergeID; loginToken.ArrivalDate = arrivalDate; loginToken.Status = status; return(true); } return(false); }
public string StringTripleDESEncrypt(string input) { var encrypted = string.Empty; using (var encrypter = new TripleDESEncryption(appConfig.TripleDESEncryptionKey)) { try { encrypted = encrypter.Encrypt(input); } catch (FormatException fe) { encrypted = string.Empty; } catch (Exception e) { encrypted = string.Empty; } } return(encrypted); }