C# Program to Illustrate how User Authentication is Done

This C# Program Illustrates how User Authentication is Done. Here The program accepts the username and password. It checks whether the password is correct with respect to the username.

  1. 
    
  2. using System;
  3. class program
  4. {
  5.     public static void Main()
  6.     {
  7.         char[] password = new char[10];
  8.         char[] username = new char[10];
  9.         char ch;
  10.         int i;
  11.  
  12.         Console.WriteLine("Enter User name < 3 characters > : ");
  13.         for (int x = 0; x < 8; x++)
  14.         {
  15.             username[x] = Convert.ToChar(Console.Read());
  16.         }
  17.         Console.WriteLine("Enter the password < any 8 characters>: ");
  18.         for (i = 0; i < 8; i++)
  19.         {
  20.             ch = Convert.ToChar(Console.Read());
  21.             password[i] = ch;
  22.             ch = '*';
  23.             Console.WriteLine("{0}", ch);
  24.         }
  25.         password[i] = '\0';
  26.         Console.WriteLine("\n Your Password is :");
  27.         for (i = 0; i < 8; i++)
  28.         {
  29.             Console.Write("{0}", password[i]);
  30.         }
  31.         Console.ReadLine();
  32.         Console.ReadLine();
  33.     }
  34. }
Here is the output of the C# Program:
Enter User name < 3 characters > :
s
r
i
Enter the password < any 8 characters>:
*
s
*
*
*
r
*
*
*
i
*
 Your Password is :
s
r
i

No comments:

Post a Comment