Caesar Cipher in C and C++ [Encryption & Decryption]

Get program for caesar cipher in C and C++ for encryption and decryption.

What is Caesar Cipher?

It is one of the simplest encryption technique in which each character in plain text is replaced by a character some fixed number of positions down to it.

For example, if key is 3 then we have to replace character by another character that is 3 position down to it. Like A will be replaced by D, C will be replaced by F and so on.

For decryption just follow the reverse of encryption process.

Caesar Cipher in C and C++ [Encryption & Decryption]

Below I have shared program to implement caesar cipher in C and C++.

Program for Caesar Cipher in C

Encryption

Output

Enter a message to encrypt: axzd
Enter key: 4
Encrypted message: ebdh

Decryption

Output

Enter a message to decrypt: ebdh
Enter key: 4
Decrypted message: axzd

Program for Caesar Cipher in C++

Encryption

Output

Enter a message to encrypt: asd zf
Enter key: 3
Encrypted message: dvg ci

Decryption

Output

Enter a message to decrypt: az GjK
Enter key: 2
Decrypted message: yx EhI

Comment below if you have doubts or found anything incorrect in above program for caesar cipher in C and C++.

4 thoughts on “Caesar Cipher in C and C++ [Encryption & Decryption]

  1. Jonathan

    What are ‘z’ and ‘a’ for exactly? Care to explain a bit on the conditional statements there?

    Reply
    1. Admin Post author

      We are checking that given character in message should be in between ‘a’ and ‘z’ or ‘A’ and ‘Z’.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *