public void Password_Fail() { string password = "******"; PurplePassword PurplePasswordInstance = new PurplePassword (); string passwordHash = PurplePasswordInstance.CreateHash (password); Assert.IsFalse(PurplePasswordInstance.ValidatePassword ("WrongPassword987?", passwordHash)); }
public static bool ValidateAuthentication(string identifier, string password_or_token) { PurpleAccount userData = get_user_reference (identifier); if(userData == null) return false; if(!string.IsNullOrEmpty(password_or_token)) { PurplePassword pp = new PurplePassword(); if(pp.ValidatePassword(password_or_token, userData.password)) { update_user_last_seen(userData); return true; } if(!String.IsNullOrEmpty(userData.token) && password_or_token == userData.token) { if(PurpleHash.GetTokenDate(userData.token) .AddDays(PurpleConfig.Account.User.Token.DaysValid) >= DateTime.Now) { update_user_last_seen(userData); return true; } } } return false; }
public void Password() { string password = "******"; PurplePassword PurplePasswordInstance = new PurplePassword (); string passwordHash = PurplePasswordInstance.CreateHash (password); Assert.IsTrue(PurplePasswordInstance.ValidatePassword (password, passwordHash)); }