Exemple #1
0
        public static BasicCredentials DecodeBasicAuthorization(string auth)
        {
            var basicCredentials = new BasicCredentials();

            try
            {
                var decoded   = Encoding.ASCII.GetString(Convert.FromBase64String(auth));
                var authArray = decoded.Split(':');
                var user      = authArray[0];
                var pass      = authArray[1];
                basicCredentials.Username = user;
                basicCredentials.Password = pass;
                basicCredentials.Error    = false;
                return(basicCredentials);
            }
            catch (Exception)
            {
                basicCredentials.Error = true;
                return(basicCredentials);
            }
        }
Exemple #2
0
 public static BasicCredentials DecodeBasicAuthorization(string auth)
 {
     var basicCredentials = new BasicCredentials();
     try
     {
         var decoded = Encoding.ASCII.GetString(Convert.FromBase64String(auth));
         var authArray = decoded.Split(':');
         var user = authArray[0];
         var pass = authArray[1];
         basicCredentials.Username = user;
         basicCredentials.Password = pass;
         basicCredentials.Error = false;
         return basicCredentials;
     }
     catch (Exception)
     {
         basicCredentials.Error = true;
         return basicCredentials;
     }
 }