1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
static void Main(string[] args)
{
string login = "";
string password = "";
Console.WriteLine("Login : ");
login = Console.ReadLine();
Console.WriteLine("Password: ");
password = Console.ReadLine();
Console.Clear();
// Create a new instance of the MD5CryptoServiceProvider object.
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
// Convert the input string to a byte array and compute the hash.
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(login + "|" + password));
StringBuilder sBuilder = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
sBuilder.Append(data[i].ToString("x2"));
}
string hash = sBuilder.ToString();
Console.WriteLine("Login : " + login + ", Hash : " + hash);
var client = new EntreprisePortClient(
new MyBasicHttpBinding(),
new EndpointAddress("http://MyWebServiceUrl")
);
client.ClientCredentials.UserName.UserName = login;
client.ClientCredentials.UserName.Password = hash;
StatusReturn output = client.status();
Console.WriteLine("Result : " + output.statusMsg);
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
} |
Partager