0% found this document useful (0 votes)
108 views6 pages

Caesar Cipher in C and C++ (

The Caesar cipher is an encryption technique where each letter in a message is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. To encrypt a message, an integer shift value is chosen which indicates how far down the alphabet each letter is moved. The algorithm takes in a string of lowercase letters called the text and an integer shift value between 0-25, then traverses the text and transforms each character according to the encryption rule based on the shift.

Uploaded by

marwaha_hitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
108 views6 pages

Caesar Cipher in C and C++ (

The Caesar cipher is an encryption technique where each letter in a message is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. To encrypt a message, an integer shift value is chosen which indicates how far down the alphabet each letter is moved. The algorithm takes in a string of lowercase letters called the text and an integer shift value between 0-25, then traverses the text and transforms each character according to the encryption rule based on the shift.

Uploaded by

marwaha_hitesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Caesar Cipher in C and C++

[Encryption & Decryption]


What is Caesar Cipher?

The Caesar Cipher technique is one of the earliest


and simplest method of encryption technique. It’s
simply a type of substitution cipher, i.e., each letter
of a given text is replaced by a letter some fixed
number of positions down the alphabet. For example
with a shift of 1, A would be replaced by B, B would
become C, and so on. The method is apparently
named after Julius Caesar, who apparently used it to
communicate with his officials.
Thus to cipher a given text we need an integer value,
known as shift which indicates the number of
position each letter of the text has been moved down.
The encryption can be represented using modular
arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,…, Z
= 25. Encryption of a letter by a shift n can be
described mathematically as.
Text : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Shift: 23 Cipher:
XYZABCDEFGHIJKLMNOPQRSTUVW Text :
ATTACKATONCE Shift: 4 Cipher:
EXXEGOEXSRGI
Algorithm for Caesar Cipher:
Input:
A String of lower case letters, called Text.
An Integer between 0-25 denoting the required shift.
Procedure:
Traverse the given text one character at a time .
For each character, transform the given character as
per the rule, depending on whether we’re encrypting
or decrypting the text.
Return the new string generated.

You might also like