Exemplo n.º 1
0
        public string ModifyPWD(string userName, string userPwd, string newUserPWd)
        {
            int             a;
            PersonManagment pm  = new PersonManagment();
            MD5             md5 = new MD5CryptoServiceProvider();

            byte[] result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(userPwd.Trim()));
            //pm.ModifyPerson_Pwd(userName, result);
            Person_Info p = pm.Get_Person(userName);

            if (p == null)
            {
                return("ModifyPWD_Index");
            }
            else
            {
                byte[] r          = p.Person_Pwd;
                string userPwdMD5 = System.Text.UTF8Encoding.Unicode.GetString(result);
                string userPwDb   = System.Text.UTF8Encoding.Unicode.GetString(r);
                if (!userPwDb.Equals(userPwdMD5))
                {
                    return("ModifyPWD_Index");
                }
                // string =System.Text.Encoding.Default.GetString(result);



                else
                {
                    result = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(newUserPWd.Trim()));
                    if (pm.ModifyPerson_Pwd(userName, result))
                    {
                        return("/Main/Home");
                    }
                    else
                    {
                        return("ModifyPWD_Index");
                    }
                }
            }
        }