Esempio n. 1
0
 public void ItCanVerifyCredentials()
 {
     const string username = "******";
     const string password = "******";
     var charArray = Encoding.UTF8.GetBytes($"{username}:{password}");
     var encodedString = Convert.ToBase64String(charArray);
     var credentials = new Credentials(username, password);
     Authenticator.Verify(credentials, encodedString).ShouldBeTrue();
 }
Esempio n. 2
0
 public static bool Verify(Credentials credentials, string encodedString)
 {
     var byteArray = Convert.FromBase64String(encodedString);
     var decodedString = Encoding.UTF8.GetString(byteArray);
     var stringElements = decodedString.Split(':');
     if (stringElements.Length < 2)
         return false;
     var username = stringElements[0];
     var password = stringElements[1];
     if (credentials.Name() == username)
         return (credentials.Password() == password);
     return false;
 }