Skip to content

An old Caesar Cipher C++ Script for Ethical Hacking Course

Notifications You must be signed in to change notification settings

Sergeant-Potato/Old_CCipher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Old CCipher

logo

Table of Contents

About the Project

Introduction

This project illustrates a basic C++ implementation of the Caesar Cipher Algorithm for the decryption of a specific hidden message for the CECS 4210 (Ethical Hacking) Course.

Getting Started

Prerequisites

In order to use this program some form of C++ Compiler must be installed. During the time this code was developed, Microsoft Visual Studio 2017 was used (link). It should be noted that the Microsoft Visual C++ package must be selected when installing the program.

Installation

After all is up an running, the only thing left to do is to open the Old_CCipher.cpp in the compiler and run it.

Usage

The Old_CCipher program can be divided into two (2) sections, where:

  1. The main will already include the encrypted message (enMsg) and the key (key) necesary to decrypt it. Furthermore, from here, the monoAlphabetic function will be called so to decrypt such encrypted message. The lines of code are shown below:
int main(){
    string enMsg = "frparnddlafmudkafcinnamifcaopmafpcasiqkacaqpnceaflikrtedqpfqdfckahvciaffdspcasiagiprcdrdnsidvkodrcgauuaqvncqepnnifmir";
    string key = "phqgiumeajlnofdybkrcvstxzw";

    cout << "Mono-Alphabetic Cipher\n\n";
    cout << "The encrypted message is: " << enMsg << endl << endl; 
    cout << "The decrypted message is: " << monoAlphabetic(enMsg,key) << endl; 
}
  1. As stated previously, the monoAlphabetic function will be tasked to decrypt the encrypted message; given that in order to do so it needs the message and key, it includes parameters for both. Furthermore, it utilizes two (2) variables, i.e.: alphabet and solution, to hold all letters of the English alphabet in order and the plaintext solution, respectively. Lastly, what follows are two nested for-loops for the generation of, well, the plaintext solution.
string monoAlphabetic(string enMsg, string key){
    const string alphabet = "abcdefghijklmnopqrstuvwxyz"; 
    string solution =""; 
    for(int i =0; i<enMsg.size();i++){
        for(int k = 0; k<key.size();k++){ 
            if(key[k] == enMsg[i]){ 
                solution = solution + alphabet[k]; 
            }
        }
    }
    return solution;
}

In all, the encrypted and decrypted messages are the following:

  • Encrypted Message: frparnddlafmudkafcinnamifcaopmafpcasiqkacaqpnceaflikrtedqpfqdfckahvciaffdspcasiagiprcdrdnsidvkodrcgauuaqvncqepnnifmir.
  • Decrypted (Plaintext) Message: nsaislookingforintelligentimaginativecriticalthinkerswhocancontributeinnovativeideastosolveourmostdifficultchallenges.

Acknowledgements

About

An old Caesar Cipher C++ Script for Ethical Hacking Course

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages