public void SetPassword(string password) { if (!IsPasswordValid(password)) { throw new CinemaException(ErrorCodes.InvalidPassword); } var encrypterService = new EncrypterService(); Salt = encrypterService.GenerateSalt(); Password = encrypterService.Compute(password, Salt); }
public void User_Change_Password_Will_Change_Salt_And_New_HashPassword(string newPassword) { var encrypterService = new EncrypterService(); var user = new User("my_login", "my_test", "my_email"); user.CreatePassword("Senha@123", encrypterService); var oldHash = user.HashPassword; var oldSalt = user.Salt; user.ChangePassword(newPassword, "Senha@123", encrypterService); Assert.AreNotEqual(user.Salt, oldSalt); Assert.AreNotEqual(user.HashPassword, oldHash); }
/// <summary> DES解密 </summary> public string DecryptByDES(string value) { return(EncrypterService.DecryptByDES(value, "12345678")); }
/// <summary> MD5加密 </summary> public string EncryptByMD5(string value) { return(EncrypterService.EncryptByMD5(value)); }