Skip to content

Instantly share code, notes, and snippets.

Created February 11, 2018 11:00
What would you like to do?
CaesarCipher turned into C++
#include <iostream>
#include <fstream>
#include <stdlib.h>
using namespace std;
Ceaser Cipher
- Julius Caesar (Inventor of July &amp; CeaserCipher)
So He basically shifted each letter in a way that the enemy thinks that it's meaningless wordless.
He applied the shift by 3, and the two parties knew in advance that they have to shift the letters by 3.
Let's use it here!
class CaesarCipher {
// parameters / props of the class
int shifts;
string message;
// Methods
void start();
void getDetails();
void performCipher();
void end();
void CaesarCipher::start() {
void CaesarCipher::getDetails() {
cout<<"Please Enter the Message to be CaesarCiphered: ";
getline(cin, message);
cout<<"\nBy What amount do you want to shift: ";
if (shifts <= 0) {
cout<<"\nYou can't shift your string by 0 or a negative number";
void CaesarCipher::performCipher() {
for(int i = 0; i < message.length(); i++) {
message[i] = char(message[i] + shifts);
void CaesarCipher::end() {
cout<<"\nThe Ciphered Message is: ";
int main() {
CaesarCipher instance;
cout<<"###@@@--- Welcome to the Ceaser Cipher ---@@@###\n";
return 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment