Connect to

facebook google Email you tube you tube you tube
Theme images by MichaelJay. Powered by Blogger.

Projects

7.3.17

Caesar Cipher Encryption Algorithm in C and C++

What is Caesar Cipher Encryption 
Algorithm?

Answer: It is a kind of Encryption where each letter in a string is replaced by a letter corresponding to a certain number of letters up or down in the alphabet series. 

For Example : If the given String is Test the encrypted version ill be : Whvw.
Explanation: Every letter was replaced by the third letter that comes after it.


Source Code in C :

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

void encrypt(char s[20])
 { int i;
    for(i=0;i<strlen(s);i++)
     { s[i] += 3;
     }
 }

void decrypt(char s[20])
 { int i;
    for(i=0;i<strlen(s);i++)
     { s[i] -= 3;
     }
 }

void main()
 { char s[20];
    clrscr();
     printf("Enter your message:");
     gets(s);
     printf("\nEncrypted Version : ");
      encrypt(s);
     printf("%s",s);
     printf("\nDecrypt Version : ");
      decrypt(s);
     printf("%s",s);
     getch();

 }


Source Code in C++ :

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

void encrypt(char s[20])
 { int i;
    for(i=0;i<strlen(s);i++)
     { s[i] += 3;
     }
 }

void decrypt(char s[20])
 { int i;
    for(i=0;i<strlen(s);i++)
     { s[i] -= 3;
     }
 }

void main()
 { char s[20];
    clrscr();
     cout<<"Enter your message : ";
      gets(s);
     cout<<"\nEncrypted Version : ";
      encrypt(s);
     cout<<s;
     cout<<"\nDecrypt Version : ";
      decrypt(s);
     cout<<s;
     getch();

 }

OUTPUT :


2 comments:
Write comments
  1. In today’s modern society, the success of most organization is somehow dependent on the quality of data they collect and information they process in their operations. All business transactions and communications are made up of data of information, some which need to be classified or highly confidential (i.e. must only be known and/or shared with selected people). To achieve this in programming, we call upon Cryptography. Cryptography is the practice and study of the techniques that are used to communicate and/or store information or data privately and securely. It is a wide field with numerous applications in our day to day communications and usage of information and data. Amongst all the techniques that are associated with Cryptography in this assignment we shall limit ourselves to encryption and decryption, which simply refers to the processes of encoding/hiding an intelligent message into something that is in an unintelligent form or gibberish that cannot be understood by anyone and vice versa. In this assignment you are required to write a program in C++ that will allow a user to encrypt and decrypt messages. The encryption algorithm should be based on the Caesar cipher. The Caesar cipher is an example of what is called the shift cipher. For the encoding, you are expected to use the following alphabet: a b c d e f g h i j 0 1 2 3 4 5 6 7 8 9 k l m n o p q r s t 10 11 12 13 14 15 16 17 18 19 u v w x y z . , ? 20 21 22 23 24 25 26 27 28 29 The program should ask the user to chose which option they wish to perform among encryption, decryption or exit of the program just after launching the program. Once the option to be performed is given the program should proceed to requesting for the text to be encrypted or decrypted and proceed to performing the action and printing out the encrypted message or decrypted message. Deliverables: ▪ Complete and detailed flowchart of the solution indicating clearly how the encryption/decryption will be achieved using the Caesar cipher ▪ A menu driven executable application ▪ Source code of the program

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete

Interested in our works and services?
Get more of our update !