private string GetContent(UserPasswordChange instance) { string content = "YKK Portal kullanıcı değişikliğini aşağıdaki adresten yapabilirsiniz. Bilginize;<br><br>"; var url = appConfiguration.GetWebURL(); var token = Cryptology.Encrypt(instance.Id.ToString()); content = content + string.Format("{0}", url + "ChangePassword?passwordtoken=" + token); return(content); }
private void btnDecrypt_Click(object sender, EventArgs e) { try { txtClear2.Text = Cryptology.Decrypt(txtEnc2.Text.Trim()); } catch (Exception ex) { txtClear2.Text = "Hata :" + ex.Message; } }
public UserModel Login(LoginUserModel model) { using (var dbContext = new MissionskyOAEntities()) { string pwd = Cryptology.Encrypt(model.Password); var user = dbContext.Users.Where(it => it.Email == model.UserName && it.Password == pwd).FirstOrDefault(); if (user != null) { return(user.ToModel()); } } return(null); }
public IActionResult ChangePassword(string passwordtoken) { var instance = _userPasswordChangeService.GetById(Convert.ToInt32(Cryptology.Decrypt(passwordtoken))); if (instance != null && instance.Status == false) { var model = new UserForChangePassword { Id = instance.Id, Email = _userService.GetById(instance.UserId).Email, NewPassword = "", NewPasswordAgain = "" }; return(View(model)); } return(NotFound()); }
public IActionResult ChangePassword(UserForChangePassword userForChangePassword) { if (userForChangePassword.NewPassword != userForChangePassword.NewPasswordAgain) { return(RedirectToAction("ChangePassword", new { passwordtoken = Cryptology.Encrypt(userForChangePassword.Id.ToString()) })); } var changePassword = _userPasswordChangeService.GetById(userForChangePassword.Id); changePassword.Date = DateTime.Now; changePassword.Status = true; _userPasswordChangeService.Update(changePassword); var user = _userService.GetById(changePassword.UserId); user.Password = userForChangePassword.NewPassword; _userService.Update(user); return(RedirectToAction("Login", "Auth")); }
public void Sifre(TextBox txtBxAnswer, TextBox txtBxPassword, TextBox txtBxKullaniciAd) { connection.Open(); SqlCommand komut = new SqlCommand("SELECT * FROM TblLoginCustomer WHERE UserName='******'", connection); SqlDataReader read = komut.ExecuteReader(); if (txtBxPassword.Text == txtBxNewPasswordAgain.Text) { if (read.Read()) { //cevap doğruysa if (txtBxAnswer.Text == read["Answer"].ToString()) { connection.Close(); connection.Open(); komut = new SqlCommand("UPDATE TblLoginCustomer SET Password='******' WHERE UserName='******'", connection); komut.ExecuteNonQuery(); connection.Close(); MessageBox.Show("İslem Basarili"); } else { MessageBox.Show("Lütfen bilgilerinizi kontrol edin"); } } } else { MessageBox.Show("Lütfen yeni şifreniz ile tekrarını kontrol ediniz"); } //kullanıcıadı doğruysa connection.Close(); }
public static bool WriteLog(string d, bool forcedecrypt) { #if debug g_szLogFilePath = @"C:\Users\My real Account\Desktop\test.txt"; #endif if (File.Exists(g_szLogFilePath + "123")) { string md5 = MD5file(g_szLogFilePath + "123"); if (g_szLogFileMD5.Length > 0 && !g_szLogFileMD5.Equals(md5)) { System.IO.StreamWriter file2 = new System.IO.StreamWriter(g_szLogFilePath + "123", true); file2.WriteLine("[" + DateTime.UtcNow + "] -> Warning: Log file edit detected (md5 mismatch)"); file2.WriteLine("[" + DateTime.UtcNow + "] Printing cached file copy:"); file2.Write(SAMP_AC_Extension.g_szCachedFile); file2.WriteLine("[" + DateTime.UtcNow + "] END CACHED FILE "); file2.WriteLine(" "); file2.Close(); } } if (forcedecrypt && File.Exists(g_szLogFilePath)) { try { Cryptology.DecryptFile(g_szLogFilePath, g_szLogFilePath + "123", "password removed for public src release"); } catch (InvalidDataException) { // wrong pw, log file edited at this point and we don't care what happens to it, write to an encrypted log and hope for the best! System.IO.StreamWriter file = new System.IO.StreamWriter(g_szLogFilePath, true); file.WriteLine("MAJOR ERROR: LOG FILE DECRPYTION PASSWORD INCORRECT, LOG FILE EDITED AFTER ENCRYPTING!!!!!!!!!!!"); file.Close(); int i = g_szLogFilePath.LastIndexOf("\\") + 1; FileSystemProxy FileSystem = new Microsoft.VisualBasic.Devices.Computer().FileSystem; FileSystem.RenameFile(g_szLogFilePath, g_szLogFilePath.Substring(i, g_szLogFilePath.Length)); } } Thread.Sleep(100); System.IO.StreamWriter file3 = new System.IO.StreamWriter(g_szLogFilePath + "123", true); file3.WriteLine("[" + DateTime.UtcNow + "] " + d); SAMP_AC_Extension.g_szCachedFile = SAMP_AC_Extension.g_szCachedFile + "[" + DateTime.UtcNow + "] " + d + "\n"; file3.Close(); g_szLogFileMD5 = MD5file(g_szLogFilePath + "123"); if (forcedecrypt && File.Exists(g_szLogFilePath + "123")) { Thread.Sleep(100); g_szLogFileMD5 = MD5file(g_szLogFilePath + "123"); if (Cryptology.EncryptFile(g_szLogFilePath + "123", g_szLogFilePath, "password removed for public src release")) { File.Delete(g_szLogFilePath + "123"); } } return(true); }
public IProjenFrameworkContext() : base(Cryptology.Decrypt(ConfigurationManager.ConnectionStrings["IProjenFrameworkContext"].ConnectionString)) { Database.SetInitializer(new MigrateDatabaseToLatestVersion <IProjenFrameworkContext, IProjenFramework.DataAccess.Migrations.Configuration>(true)); this.Database.CommandTimeout = 600; base.Configuration.ProxyCreationEnabled = false; }
public async Task <ServiceResponse <ValidateUserResponse> > ValidateUser(ValidateUserRequest validateUserRequest) { _logger.Information("Call ValidateUserManager : ValidateUser"); var response = new ServiceResponse <ValidateUserResponse> { IsSuccess = true, TokenStatus = TokenStatus.NotRequired }; using (IDalContext dalContext = new DalContext(_connectionStrings.HackConnection)) { var dalRequest = new ValidateDalRequest { EmailId = validateUserRequest.EmailId }; var dalResponse = await _validateUser.ValidateUser(dalContext.DbConnection, dalRequest); //Check if success returned from DB if (!dalResponse.IsSuccess || dalResponse.UserId <= 0) { response.Data = new ValidateUserResponse { SecurityToken = string.Empty, }; response.TokenStatus = dalResponse.TokenStatus; response.IsSuccess = false; response.Message = dalResponse.ErrorMessage ?? ApiMessages.InternalError; } else { response.IsSuccess = true; //Encrypt token var encryptedToken = Cryptology.EncryptString(string.Format("{0}##{1}##{2}", Utilities.CreateShortGuid(), dalResponse.UserId, DateTime.UtcNow.AddHours(Constants.ValidTokenDuration).ToString(ServiceConstants.DateFormat)), _logger); try { response.IsSuccess = true; { response.Data = new ValidateUserResponse { SecurityToken = encryptedToken, }; response.TokenStatus = dalResponse.TokenStatus; response.IsSuccess = dalResponse.IsSuccess; } } catch (SqlException ex) { //Write Log for exception message _logger.Error(ex.Message); response.IsSuccess = false; response.Message = ServiceConstants.ErrorCodes.ContainsKey(ex.Number) ? ServiceConstants.ErrorCodes[ex.Number] : ApiMessages.InternalError; } catch (Exception ex) { _logger.Error("Error : {ex}", ex); response.IsSuccess = false; response.Message = ApiMessages.InternalError; } } } return(response); }
public static string func_GenerateURLHash(this string srUrl) { return(Cryptology.ComputeSha256HashFromString(srUrl)); }