caesar cipher program in c++
C++
// A C++ program to illustrate Caesar Cipher Technique
#include <iostream>
using namespace std;
// This function receives text and shift and
// returns the encrypted text
string encrypt(string text, int s)
{
string result = "";
// traverse text
for (int i=0;i<text.length();i++)
{
// apply transformation to each character
// Encrypt Uppercase letters
if (isupper(text[i]))
result += char(int(text[i]+s-65)%26 +65);
// Encrypt Lowercase letters
else
result += char(int(text[i]+s-97)%26 +97);
}
// Return the resulting string
return result;
}
// Driver program to test the above function
int main()
{
string text="ATTACKATONCE";
int s = 4;
cout << "Text : " << text;
cout << "\nShift: " << s;
cout << "\nCipher: " << encrypt(text, s);
return 0;
}
Also in C++:
- Title
- c++ wait for user input
- Category
- C++
- Title
- coping 2d vector in cpp
- Category
- C++
- Title
- insert function in c++ vector
- Category
- C++
- Title
- maximum subarray sum equal with K in c++
- Category
- C++
- Title
- modulo c++
- Category
- C++
- Title
- case label in c++
- Category
- C++
- Title
- pionter in c++
- Category
- C++
- Title
- find in set of pairs using first value cpp
- Category
- C++
- Title
- variabvles in c++
- Category
- C++
- Title
- c++ public inheritance not getting protected
- Category
- C++
- Title
- checking an int in c++
- Category
- C++
- Title
- how to cout in c++
- Category
- C++
- Title
- check for bst
- Category
- C++
- Title
- mysqli connect
- Category
- C++
- Title
- statement that causes a function to end in c++
- Category
- C++
- Title
- prefix sum array
- Category
- C++
- Title
- generate random double c++
- Category
- C++
- Title
- c++ convert int to double
- Category
- C++
- Title
- eratosthenis sieve in c++
- Category
- C++
- Title
- c++ string to vector int
- Category
- C++
- Title
- euler's totient function c++
- Category
- C++
- Title
- sort function in cpp
- Category
- C++
- Title
- runtime array size c++
- Category
- C++
- Title
- bool function in c++
- Category
- C++
- Title
- inserting an element in an set c++
- Category
- C++
- Title
- translate
- Category
- C++
- Title
- what are the different ways to traverse a binary tree
- Category
- C++
- Title
- count number of zeros in array in O(logN)
- Category
- C++
- Title
- char **
- Category
- C++
- Title
- print matrix c++
- Category
- C++
- Title
- how to delete an element in vector pair in cpp
- Category
- C++
- Title
- how to get last element of set in c++
- Category
- C++
- Title
- switch c++
- Category
- C++
- Title
- c++ compare char array
- Category
- C++
- Title
- matrix transpose tiling
- Category
- C++
- Title
- how long can a c++ string be
- Category
- C++
- Title
- transpose matrix eigen c++
- Category
- C++
- Title
- how to format decimal palces in c++
- Category
- C++
- Title
- zeros of array c++
- Category
- C++
- Title
- how to swap string characters in c++
- Category
- C++
- Title
- new keyword in cpp
- Category
- C++
- Title
- run program until ctrl-d c++
- Category
- C++
- Title
- how to iterate through array in c++
- Category
- C++
- Title
- min coin change problem dp
- Category
- C++
- Title
- C++ Syntax
- Category
- C++
- Title
- regexp_like oracle c++
- Category
- C++
- Title
- how to print eachh chars in string data type in c++
- Category
- C++
- Title
- remove value from vector c++
- Category
- C++
- Title
- c++ excel cell blank cells
- Category
- C++
- Title
- switch statement c++
- Category
- C++
- Title
- c++ convert int to cstring
- Category
- C++
- Title
- binary representation differ in bits
- Category
- C++
- Title
- function declerations in C++
- Category
- C++
- Title
- c++ remove space from string
- Category
- C++
- Title
- getline in c++
- Category
- C++
- Title
- how to get a letter from the user c++ string
- Category
- C++
- Title
- how to check datatype of a variable in c++
- Category
- C++
- Title
- lisy stl C++
- Category
- C++
- Title
- dynamic 2d array c++
- Category
- C++
- Title
- array search c++
- Category
- C++
- Title
- friend function in c++
- Category
- C++
- Title
- how to print a string to console in c++
- Category
- C++
- Title
- hobo 8
- Category
- C++
- Title
- graph using djacency matrix c++
- Category
- C++
- Title
- c++ create array
- Category
- C++
- Title
- range based for loop c++ with reference
- Category
- C++
- Title
- c++ switch
- Category
- C++
- Title
- c++ class constructor
- Category
- C++
- Title
- c++ looping through a vector
- Category
- C++
- Title
- matrix multiplication c++ eigen
- Category
- C++
- Title
- never gonna give you up lyrics
- Category
- C++
- Title
- set c++
- Category
- C++
- Title
- #include
- Category
- C++
- Title
- c++ map find
- Category
- C++
- Title
- program to know if a number is prime
- Category
- C++
- Title
- binary tree deletion
- Category
- C++
- Title
- do while loop c++
- Category
- C++
- Title
- c++ convert const char* to LPCWSTR
- Category
- C++
- Title
- how to get the prime number in c++ where time complexity is 0(log n)
- Category
- C++
- Title
- how to sort an array c++
- Category
- C++
- Title
- static variable in c++
- Category
- C++
- Title
- c++ char print align
- Category
- C++
- Title
- Find the minimum difference between pairs in a simple path of tree C++
- Category
- C++
- Title
- unsorted array to bst
- Category
- C++
- Title
- how to sort a vector in c++
- Category
- C++
- Title
- int max in c++
- Category
- C++
- Title
- printf c++
- Category
- C++
- Title
- c++ overload operator
- Category
- C++
- Title
- C++ int to char*
- Category
- C++
- Title
- how to make a 2d vector in c++
- Category
- C++
- Title
- level order traversal
- Category
- C++
- Title
- jump to case label c++
- Category
- C++
- Title
- error: invalid use of template-name without an argument list
- Category
- C++
- Title
- unordered_set in c++ and ordered set diff
- Category
- C++
- Title
- nth_element c++
- Category
- C++
- Title
- if vector contains value c++
- Category
- C++
- Title
- c++ char to string
- Category
- C++
- Title
- rand c++
- Category
- C++
- Title
- stack c++
- Category
- C++
- Title
- find in vector in c++
- Category
- C++