SlideShare a Scribd company logo
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];
}
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++){
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();
}

More Related Content

What's hot

Python programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphismPython programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphism
Emertxe Information Technologies Pvt Ltd
 
Play fair cipher
Play fair cipherPlay fair cipher
Play fair cipher
Khawar Abbas
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1
Tom Henricksen
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back trackingTech_MX
 
Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
Muhammad Muzammal
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
Alamgir Hossain
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
Ashok Raj
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.
mohanrathod18
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahniHitesh Wagle
 
Time complexity
Time complexityTime complexity
Time complexity
Kartik Chandra Mandal
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAdelina Ahadova
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
Rezwan Siam
 
Examples of Informed Search
Examples of Informed SearchExamples of Informed Search
Examples of Informed Search
Sagacious IT Solution
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
mohanrathod18
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
Vinod Kumar
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
Sujith Kumar
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
Soba Arjun
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
Abdul Rehman
 

What's hot (20)

Python programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphismPython programming : Inheritance and polymorphism
Python programming : Inheritance and polymorphism
 
Play fair cipher
Play fair cipherPlay fair cipher
Play fair cipher
 
Head First Java Chapter 1
Head First Java Chapter 1Head First Java Chapter 1
Head First Java Chapter 1
 
Backtracking
BacktrackingBacktracking
Backtracking
 
8 queens problem using back tracking
8 queens problem using back tracking8 queens problem using back tracking
8 queens problem using back tracking
 
Algorithmic Notations
Algorithmic NotationsAlgorithmic Notations
Algorithmic Notations
 
Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.Lab report for Prolog program in artificial intelligence.
Lab report for Prolog program in artificial intelligence.
 
Command line arguments
Command line argumentsCommand line arguments
Command line arguments
 
Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.Mathematical Analysis of Non-Recursive Algorithm.
Mathematical Analysis of Non-Recursive Algorithm.
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
 
Fundamentals of data structures ellis horowitz & sartaj sahni
Fundamentals of data structures   ellis horowitz & sartaj sahniFundamentals of data structures   ellis horowitz & sartaj sahni
Fundamentals of data structures ellis horowitz & sartaj sahni
 
Time complexity
Time complexityTime complexity
Time complexity
 
Algorithm Complexity and Main Concepts
Algorithm Complexity and Main ConceptsAlgorithm Complexity and Main Concepts
Algorithm Complexity and Main Concepts
 
Bruteforce algorithm
Bruteforce algorithmBruteforce algorithm
Bruteforce algorithm
 
Examples of Informed Search
Examples of Informed SearchExamples of Informed Search
Examples of Informed Search
 
Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.Mathematical Analysis of Recursive Algorithm.
Mathematical Analysis of Recursive Algorithm.
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Recursion in c++
Recursion in c++Recursion in c++
Recursion in c++
 

More from Sanjay Kumar Chakravarti

Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Sanjay Kumar Chakravarti
 
Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.
Sanjay Kumar Chakravarti
 
Microassembler a10
Microassembler a10Microassembler a10
Microassembler a10
Sanjay Kumar Chakravarti
 
Micro Assembler
Micro AssemblerMicro Assembler
Micro Assembler
Sanjay Kumar Chakravarti
 

More from Sanjay Kumar Chakravarti (8)

Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.
 
Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.Design A Screen saver in c on Moving Train with Side view.
Design A Screen saver in c on Moving Train with Side view.
 
Microassembler a10
Microassembler a10Microassembler a10
Microassembler a10
 
Micro Assembler
Micro AssemblerMicro Assembler
Micro Assembler
 
Graphical representation of Stack
Graphical representation of StackGraphical representation of Stack
Graphical representation of Stack
 
Design problem
Design problemDesign problem
Design problem
 
Computer Network
Computer NetworkComputer Network
Computer Network
 
Structured Analysis and Structured Design
Structured Analysis and Structured DesignStructured Analysis and Structured Design
Structured Analysis and Structured Design
 

IMPLEMENTATION OF AUTO KEY IN C++