Exemplo n.º 1
0
        public static ProcessedPassword EncriptarString(string ToEncrypt, string salt)
        {
            string hash;

            using (SHA512 sha512Hash = SHA512.Create())
            {
                byte[] bytes = sha512Hash.ComputeHash(Encoding.UTF8.GetBytes(ToEncrypt + salt));
                hash = Convert.ToBase64String(bytes, 0, bytes.Length);
            }
            ProcessedPassword password = new ProcessedPassword(hash, salt);

            return(password);
        }
Exemplo n.º 2
0
        public static async Task <bool> Login(string UN, string PW)
        {
            bool res = false;

            try
            {
                List <List <object> > ResParaSalt = await Querys.SelectQuery("PasswordSalt", "Users", "Username = '******'");

                string                Salt           = ResParaSalt[0][0].ToString();
                ProcessedPassword     Password       = PassEncript.EncriptarString(PW, Salt);
                List <List <object> > ResultadoFinal = await Querys.SelectQuery("*", "Users", "Username = '******' AND " + "PasswordHash = '" + Password.Hash + "'");

                if (ResultadoFinal[0][0].ToString() != "0RES")
                {
                    res = true;
                }
            }
            catch (Exception e)
            {
                res = false;
            }
            return(res);
        }