Sanjay Kumar Chakravarti
//IMPLEMENTATION OF AUTO KEY IN C++

#include<iostream.h>
#include<conio.h>
#include<string.h>
vo...
int j,k;

for(i=0;i<plen;i++){
for(j=0;j<26;j++){
if(plain[i]==alp[j]){
ct[i]=j;
for(k=0;k<26;k++){
if(key[i]==alp[k]){
ct...
if(key[i]==alp[k]){
ct1[i]-=k;
}
}
}
}
}
cout<<"nOriginal Plain Text will be:";
for(i=0;i<plen;i++){
ct1[i]=ct1[i]% 26;
if...
Upcoming SlideShare
Loading in …5
×

IMPLEMENTATION OF AUTO KEY IN C++

1,047 views

Published on

This is basic c++ program to implement the autokey Encryption.

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,047
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
30
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

IMPLEMENTATION OF AUTO KEY IN C++

  1. 1. Sanjay Kumar Chakravarti //IMPLEMENTATION OF AUTO KEY IN C++ #include<iostream.h> #include<conio.h> #include<string.h> void main(){ clrscr(); char *plain,*key,alp[]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; int plen,klen,i,count=0,ct[50]; cout<<"nntt*******This Program Done By:Sanjay Kumar Chakravarti**********"; cout<<"nEnter Text:"; cin>>plain; cout<<"nEnter Key:"; cin>>key; plen=strlen(plain); klen=strlen(key); if(klen<plen){ for(i=klen;i<plen;i++){ key[i]=plain[count]; count++; } } cout<<"nNow Key will be:"; for(i=0;i<plen;i++){ cout<<key[i]; }
  2. 2. int j,k; for(i=0;i<plen;i++){ for(j=0;j<26;j++){ if(plain[i]==alp[j]){ ct[i]=j; for(k=0;k<26;k++){ if(key[i]==alp[k]){ ct[i]+=k; } } } } } char *cih; cout<<"nCipher Text will be:"; for(i=0;i<plen;i++){ ct[i]=ct[i]% 26; cih[i]=alp[ct[i]]; //cout<<ct[i]<<" "; cout<<alp[ct[i]]; } cout<<"nttDecryption:"; int ct1[50]; for(i=0;i<plen;i++){ for(j=0;j<26;j++){ if(cih[i]==alp[j]){ ct1[i]=j; for(k=0;k<26;k++){
  3. 3. if(key[i]==alp[k]){ ct1[i]-=k; } } } } } cout<<"nOriginal Plain Text will be:"; for(i=0;i<plen;i++){ ct1[i]=ct1[i]% 26; if(ct1[i]<0){ ct1[i]=ct1[i]+26; } //cih[i]=alp[ct1[i]]; //cout<<ct[i]<<" "; cout<<alp[ct1[i]]; } getch(); }

×