Ejemplo n.º 1
0
        public static void ChangePassword(string nickName, string newPassword)
        {
            Users.Remove(nickName);
            string hashedPassword = CryptoProvider.GetMd5Hash(newPassword);

            Users.Add(nickName, hashedPassword);
        }
Ejemplo n.º 2
0
        /// <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));
        }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
        /// <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);
        }