using CoviDok.Api;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace CoviDok.Data.Model
{
    public class RoleUser : User
    {
        public Role Role { get; set; }

        public string Email { get; set; }
        
        public string Phone { get; set; }
        public string Password { get; set; }
        private static byte[] GetHash(string inputString)
        {
            using (HashAlgorithm algorithm = SHA512.Create())
                return algorithm.ComputeHash(Encoding.UTF8.GetBytes(inputString));
        }
        public static string GetHashString(string inputString)
        {
            StringBuilder sb = new StringBuilder();
            foreach (byte b in GetHash(inputString))
                sb.Append(b.ToString("X2"));

            return sb.ToString();
        }

        public bool CheckPassword(string Candidate)
        {
            return GetHashString(Candidate) == Password;
        }


    }
}