コード例 #1
0
        public ActionResult GetSecondPassword(DoorInput input)
        {
            int    index       = 0;
            string startstring = new String('-', 8);

            char[] password = startstring.ToCharArray();
            while (password.Any(x => x == '-'))
            {
                string hash = CalculateMD5Hash(input.DoorID + index.ToString());
                if (hash.Substring(0, 5) == "00000")
                {
                    int hashIndex;
                    if (int.TryParse(hash[5].ToString(), out hashIndex))
                    {
                        if (hashIndex < 8 && password[hashIndex] == '-')
                        {
                            password[hashIndex] = hash[6];
                        }
                    }
                }
                index++;
            }
            DoorPassword pass = new DoorPassword();

            pass.Password = new String(password);
            return(PartialView("Password", pass));
        }
コード例 #2
0
        public ActionResult GetPassword(DoorInput input)
        {
            int           index    = 0;
            StringBuilder password = new StringBuilder();

            while (password.Length < 8)
            {
                string hash = CalculateMD5Hash(input.DoorID + index.ToString());
                if (hash.Substring(0, 5) == "00000")
                {
                    password.Append(hash[5]);
                }
                index++;
            }
            DoorPassword pass = new DoorPassword();

            pass.Password = password.ToString();
            return(PartialView("Password", pass));
        }
コード例 #3
0
        // GET: Day6
        public ActionResult Index()
        {
            DoorInput input = new DoorInput();

            return(View(input));
        }