public static TemporaryFile SecureFileUncrypt(this ICakeContext context, FilePath file, string secret) { string extension = file.GetExtension(); if (extension == "enc") { extension = file.GetFilenameWithoutExtension().GetExtension(); } var f = new TemporaryFile(extension); RijndaelCrypt.Decrypt(file.FullPath, f.Path, secret); return(f); }
/// <summary> /// 解密数据 /// </summary> /// <param name="decryptString"></param> /// <returns></returns> public static string DecryptData(string decryptString) { if (string.IsNullOrEmpty(decryptString)) { throw new ArgumentNullException("DecryptDBConnString()方法,参数decryptString值为空"); } string key = GetEncryptKey(); if (string.IsNullOrEmpty(key)) { throw new Exception("配置中未读取到客户密钥串"); } return(RijndaelCrypt.Decrypt(decryptString, key)); }
public IActionResult ResetPwd(string u) { var rg = new RijndaelCrypt(); var uname = rg.Decrypt(u); var user = this._context.Users.Include(i => i.UserRole).Where(w => w.UserName == uname).FirstOrDefault(); if (user != null) { if (user != null && user.Status == UserStatusType.Active) { this._loginServices.Login(user, true); return(RedirectToAction("ResetPwd", "Customer")); } } ViewData["ErrorMessage"] = "พบข้อผิดพลาด"; return(RedirectToAction("Login", "Accounts")); }
private void btnDecode_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(rtxtEncryString.Text)) { MessageBox.Show("加密串不能为空"); return; } if (string.IsNullOrEmpty(txtSecretKey.Text)) { MessageBox.Show("密钥不能为空"); return; } string str = RijndaelCrypt.Decrypt(rtxtEncryString.Text.Trim(), txtSecretKey.Text.Trim()); rtxtString.Text = str; }
private void EncryptPassword() { if (txtInput.Text.Length == 0) { return; } EncryptionElement element = comboApplicationId.SelectedItem as EncryptionElement; try { if (element != null) { txtOutPut.Text = checkDecrypt.Checked ? RijndaelCrypt.Decrypt(txtInput.Text, element.ApplicationId) : RijndaelCrypt.Encrypt(txtInput.Text, element.ApplicationId); } txtOutPut.BackColor = SystemColors.Control; txtOutPut.ForeColor = SystemColors.WindowText; } catch (Exception ex) { txtOutPut.Text = ex.Message; txtOutPut.BackColor = Color.Red; txtOutPut.ForeColor = Color.White; } }
public async Task <IActionResult> SSO(SSODTO model) { if (string.IsNullOrEmpty(model.u)) { model.u = model.UserName; } if (string.IsNullOrEmpty(model.p)) { model.p = model.Password; } if (string.IsNullOrEmpty(model.p)) { model.p = model.u; } if (!string.IsNullOrEmpty(model.u) && !string.IsNullOrEmpty(model.p)) { var rg = new RijndaelCrypt(); var u = rg.Decrypt(model.u); var p = rg.Decrypt(model.p); var f = ""; if (!string.IsNullOrEmpty(model.f)) { f = rg.Decrypt(model.f); } if (!string.IsNullOrEmpty(model.facebookFlag)) { f = model.facebookFlag; } var user = this._context.Users.Include(w => w.UserRole).Where(w => w.UserName == u).FirstOrDefault(); /*create customer imobile*/ _logger.LogWarning(DateUtil.Now() + ""); _logger.LogWarning("SSO"); _logger.LogWarning(JsonConvert.SerializeObject(model)); model.u = u; if (user == null) { await this.Repair(u, p, f, "loginForStatus"); user = this._context.Users.Include(u2 => u2.UserRole).Where(u2 => u2.UserName == u).FirstOrDefault(); } if (user != null) { if (user.Status != UserStatusType.InActive) { var customer = this._context.Customers.Where(w => w.UserID == user.ID).FirstOrDefault(); if (customer == null) { ViewData["ErrorMessage"] = "ไม่พบข้อมูลผู้ใช้"; _logger.LogWarning(ViewData["ErrorMessage"].ToString()); return(RedirectToAction("Login", "Accounts", new { message = ViewData["ErrorMessage"] })); } f = customer.FacebookFlag; var valid = false; if (!string.IsNullOrEmpty(f) && f.ToLower() == "y") { valid = true; } else { if (customer.BCryptPwd == p) { valid = true; } if (!valid) { if (!string.IsNullOrEmpty(user.Password)) { string paintTextPassword = DataEncryptor.Decrypt(user.Password); string passworeInDB = p; if (!valid) { if (!string.IsNullOrEmpty(paintTextPassword) && !string.IsNullOrEmpty(passworeInDB)) { try { if (BCrypt.Net.BCrypt.Verify(paintTextPassword, passworeInDB)) { valid = true; } } catch { } } } } } if (!valid) { if (!string.IsNullOrEmpty(user.Password)) { string desPassword = DataEncryptor.Decrypt(user.Password); if (p == desPassword) { valid = true; } } } } if (valid) { this._loginServices.Login(user, true); GetCustomerClass(customer); customer.FirstLogedIn = true; this._context.SaveChanges(); return(RedirectToAction("Privilege", "Home", new { /*poppromo = 1 */ })); } } else { ViewData["ErrorMessage"] = "ถูกระงับการเป็นสมาชิก"; _logger.LogWarning(ViewData["ErrorMessage"].ToString()); return(RedirectToAction("Login", "Accounts", new { message = ViewData["ErrorMessage"] })); } } } ViewData["ErrorMessage"] = "รหัสผู้ใช้ หรือ รหัสผ่านไม่ถูกต้อง"; _logger.LogWarning(ViewData["ErrorMessage"].ToString()); return(RedirectToAction("Login", "Accounts", new { message = ViewData["ErrorMessage"] })); }
public string DecodeCredentials(string cipher) { return(RijndaelCrypt.Decrypt(cipher, AppIdentifier())); }
public static string Decode(string cipher) { return(RijndaelCrypt.Decrypt(cipher, AppIdentifier)); }