Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

CODING IN C++ Type of Cipher is Simple Substitution Write a script to apply the

ID: 3746828 • Letter: C

Question

CODING IN C++

Type of Cipher is Simple Substitution

Write a script to apply the right form of cryptoanalysis able to disclose the plaintext of the text below. Hint: it's the lyrics of a song. FCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKF CGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFC GUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCG UNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGU NKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUN KBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNK BHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKB HEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBH EJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHEJGCLKFCGUNKBHE JGCLKFCGUNKBHEJGCLK

Explanation / Answer

#include <cctype>

#include <string>

#include <iostream>

using namespace std;

void decrypt(char * input, unsigned int offset) {

for (int i = 0; input[i] != 0; i++) {

// Skip spaces...

if (input[i] == ' ')

continue;

char firstLetter = islower(input[i]) ? 'a' : 'A';

unsigned int alphaOffset = input[i] - firstLetter;

int newAlphaOffset = alphaOffset - offset;

if (newAlphaOffset < 0) {

newAlphaOffset += 26;

}

input[i] = firstLetter + (newAlphaOffset % 26);

}

}

int main()

{

std::string alphabeticalString = "acbdefghijklmnopqrstuvwxyz";

unsigned int encryptionOffset;

cout << "Please enter a Text to Decrypt : ";

cin >> alphabeticalString;

cout << "Please enter a offset level of decryption: range from 1 to 25 ";

cin >> encryptionOffset;

decrypt(const_cast<char*>(alphabeticalString.c_str()), encryptionOffset);

cout << "" in: "" << alphabeticalString << """ << endl;

return 0;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote