Password program in c language.

             Password program in c language

This blog is about how we can mask our password with asterisk in c language.It helps in strengthen our security purposes.We have seen it's application in various field's in facebook login,gmail login etc.It helps in hiding our privacy from intruder .Let's discuss the concept behind it.


      My program will perform the task of hiding  password.It will mask the password with asterisk.
         For example it will give output like this
            
                          Enter password:123456789
                          Your password:*********
     
     It will mask password with asterisk.
      

               
https://programminghub1999.blogspot.com/2018/12/password-program-in-c-language_29.html
                      

               Masking password with asterisk

      Following method has used in program.
  1. Enter the password from user.
  2. Perform the different operation whenever user will press Enter,Backspace,Tab,Space.
  3. Whenever user will press Enter it will show password mask with asterisk.
  4. At last it will show real password.
  

                               C program to mask password

This program has run in turbo editor.I personally use this editor for writing my c language program.
I have used #define inside program because to make program more understandable for user.Because if i use 13 in place of ENTER then it become difficult for user to understand the program.If i only use ENTER,BKSP,SPACE,TAB inside if() condition then computer will not be able to understand the program.I have used ASCII value of ENTER,TAB,BKSP,SPACE for computer to make it more understandable.


#include<stdio.h>
#include<conio.h>
#include<string.h>
#define ENTER 13
#define TAB 9
#define BKSP 8
#define SPACE 32
void main()
{
     clrscr();
     int i=0;
     char ch,password[30];
     printf("Enter your password\n");
     while(1)
     {
          ch=getch();
          if(ch==ENTER)
          {
               password[i]='\0';
               break;
          }
         else
                 if(ch==BKSP)
                 {
                    if(i>0)
                    {
                         i--;
                         printf("\b \b");
                     }
                  }
           else
                if(ch==TAB||ch==SPACE)
                 {
                        continue;
                 }
            else
                 {
                     password[i]=ch;
                     i++;
                     printf("*");
                 }
          }
             printf("Your password is %s",password);
             getch();
 }

            





Password program in c language. Password program in c language. Reviewed by Deepak kumar soni on December 29, 2018 Rating: 5

No comments:

Powered by Blogger.