public static void ChangePassword(string nickName, string newPassword) { Users.Remove(nickName); string hashedPassword = CryptoProvider.GetMd5Hash(newPassword); Users.Add(nickName, hashedPassword); }
/// <summary> /// Checks if input cookies values macth /// So it lets know if account is authorized yet /// </summary> /// <param name="cookiesId">Cookie that contains id</param> /// <param name="cookiesHash">Cookie that contains id hash to be matched</param> /// <returns>Result of chacking</returns> public static bool IsAuthorizedAccount(HttpCookie cookiesId, HttpCookie cookiesHash) { if (cookiesId == null || cookiesHash == null) { return(false); } var hashedId = CryptoProvider.GetMd5Hash(cookiesId.Value); return(string.Equals(hashedId, cookiesHash.Value)); }
/// <summary> /// Checks if nickname matches its password's hash /// Use it only to check log in values /// </summary> /// <param name="nickname">User's nickname</param> /// <param name="password">User's password</param> /// <returns>Result of checking</returns> public static bool PasswordMatch(string nickname, string password) { string hashedPassword = CryptoProvider.GetMd5Hash(password); return(string.Equals(Users[nickname], hashedPassword)); }
/// <summary> /// Allows to register new user into internal users collection /// </summary> /// <param name="nickname">User's nickname (it should be unique)</param> /// <param name="password">User's password</param> public static void RegisterUser(string nickname, string password) { string hashedPassword = CryptoProvider.GetMd5Hash(password); Users.Add(nickname, hashedPassword); }