WAP to Implement Creaser Cipher Algorithm


            #include<stdio.h>
#include<conio.h>
#include<string.h>

void enc(char p[]);
void dec(char c[]);
int k;
void main()
{
                        char p[20];
                        clrscr();
                        printf("enter the plaintext:");
                        scanf("%s",&p);
                        printf("enter the key:");
                        scanf("%d",&k);
                        enc(p);
            getch();
}
void enc(char p[])
{
                        int i;
                        char c[50];
                        for(i=0;i<strlen(p);i++)
                        {
                                    c[i]=p[i]+k;
                                    if((c[i]>90 && c[i]<94)||(c[i]>122 && c[i]<126))
                                    c[i]=p[i]+k-26;
                        }
                                    c[i]=NULL;
                                    printf("encrypted message: %s",c);
                                    dec(c);
}
void dec(char c[])
{
                        int i;
                        char p[100];
                        for(i=0;i<strlen(c);i++)
                        {
                                    p[i]=c[i]-k;
                                    if((c[i]>64 && c[i]<69)||(c[i]>96 && c[i]<100))
                                    p[i]=c[i]-k+26;
                        }
                                    p[i]=NULL;
                                    printf("\n decrypted message:%s",p);
}

Related Posts Plugin for WordPress, Blogger...

Engineering material

GTU IDP/ UDP PROJECT

GTU IDP/ UDP PROJECT

Patel free software download

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP