Mono Alphabetic Encryption DCN

This program is for implementing Mono-Alphabetic Encryption . This is a part of Mumbai University MCA Colleges Data Communication and Networking MCA Sem 4

#include<stdio.h>
#include<conio.h>
void main()
{
            char str[100],ckey[3];
            int encr[100],key;
            int i,j,k,tmp;
            clrscr();
            printf("Enter String : ");
            gets(str);
            printf("Enter key : ");
            gets(ckey);

            k=ckey[0];
            if(k>=49 && k<=58)
            {
                        key=0;
                        k=strlen(ckey);
                       

for(i=0;i<k;i++)
                        {
                                    tmp=ckey[i]-48;
                                    tmp=tmp%10;
                                    key=(key*10)+tmp;
                        }
            }

            if(k>=65 && k<=90)
            {
                        key=1;
                        tmp=65;
                        while(tmp!=k)
                        {
                                    key++;
                                    tmp++;
                        }
            }
            if(k>=97 && k<=123)
            {
                        key=1;
                        tmp=97;
                        while(tmp!=k)
                        {
                                    key++;
                                    tmp++;
                        }
            }

            for(i=0;str[i]!='\0';i++)
            {
                        if(str[i]>=65 && str[i]<=90)
                        {
                                    encr[i]=str[i]+key;
                                    if(encr[i]>90)
                                    {
                                                j=encr[i]-90;
                                                encr[i]=64+j;
                                     }
                        }
                        else
                        {
                                    encr[i]=str[i]+key;
                                    if(encr[i]>122)
                                    {
                                                j=encr[i]-122;
                                                encr[i]=96+j;
                                    }
                        }
                        printf("%c",encr[i]);
            }
getch();
}

Hope this Program is useful to you in some sense or other. Keep on following this blog for more Mumbai University MCA College Programs. Happy Programming and Studying.

No comments:

Post a Comment