Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions Assignment 1/210479/code.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#include <iostream>
using namespace std;

string encrypt(string text, string key) {
string encryptedText = "";
int keyIndex = 0;
for (int i = 0; i < text.length(); i++) {
if (isalpha(text[i])) {
char base = isupper(text[i]) ? 'A' : 'a';
char encryptedChar = (text[i] - base + key[keyIndex % key.length()] - 'a' + 1) % 26 + base;
encryptedText += encryptedChar;
keyIndex++;
}
else {
encryptedText += text[i];
}
}
return encryptedText;
}

int main() {
string input = "tbzvoclymifqef, kdr jriq ioklzbwbf, vzqgdgu iurqqivajp, fvsqpqket fwb wesmieqdnnab hfeotp qw rzroaggudk. afhd hhkcye, nlwi eqabpkyqhp rleejfv fs wclycrpvb, ceq kdrt laipsgivzv agkrdbfprgudk jriq abf pbg il vyve blovaf, iekj txdokfhe blovaf dc vivgbmj. pbgg hgp ga hrevfe pkf kuq exujjaga kj gtt_cwe_umh_lpcl_ntdwe.";
string key = "imnkcx";

string encryptedText = encrypt(input, key);
cout << encryptedText << endl;

    return 0;
}
8 changes: 8 additions & 0 deletions Assignment 1/210479/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**Title:** Vigenère Cipher Triumph

---

**Description:**
In this example, we encounter a Vigenère cipher, a polyalphabetic substitution cipher that employs a varying shift for each character. Our task is to decipher the encoded message and uncover the key used for encryption. To accomplish this, we investigate the website google.com, specifically focusing on the "I'm Feeling Lucky" button. After several attempts, we discover the key "rnmpx" within the division class of this button.

After unraveling the encryption, we unveil the final password: "congratulations, you have triumphed, emerged victorious, defeating the unfathomable forces of encryption. your skills, your relentless pursuit of knowledge, and your unwavering determination have led you to this moment, this glorious moment of triumph. your key to success and the password is the_fun_has_only_begun."
83 changes: 83 additions & 0 deletions Assignment 2/210479/code1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#include <iostream>
#include <string>

using namespace std;

string decryptText(const string& cipherText) {
string decryptedText;
int index = 0;
while (index < cipherText.length()) {
char characters[5];
string interstitials[5];
for (int curIndex = 0; curIndex < 5; curIndex++) {
if (isalpha(cipherText[index])) {
characters[curIndex] = cipherText[index];
// Take all the non-letters with it too
while (!isalpha(cipherText[index + 1]) && index < cipherText.length() - 1)
interstitials[curIndex] += cipherText[++index];
}
index++;
}
// Concatenate in new order
decryptedText += characters[3] + interstitials[0] + characters[2] + interstitials[1] +
characters[4] + interstitials[2] + characters[0] + interstitials[3] + characters[1] + interstitials[4];
}

string substitutionRules[] = { "Ow", "Aq", "Ta", "Sl", "Ph", "Ev", "Hf", "Gg", "Ud", "Rn", "Km", "Wr", "Dp", "Ic", "Ny", "Bj",
"Fs", "Ce", "Lt", "Yx", "Qi", "Mu", "Jk", "Vb" };

for (string rule : substitutionRules) {
size_t pos = decryptedText.find(rule[1]);
while (pos != string::npos) {
decryptedText.replace(pos, 1, string(1, rule[0]));
pos = decryptedText.find(rule[1], pos + 1);
}
}

return decryptedText;
}

int main() {
string cipherText = "qmnjvsa nv wewc flct vprj tj tvvplvl fv xja vqildhc "
"xmlnvc nacyclpa fc gyt vfvw. fv wgqyp, pqq pqcs y wsq "
"rx qmnjvafy cgv tlvhf cw tyl aeuq fv xja tkbv cqnsqs. "
"lhf avawnc cv eas fuqb qvq tc yllrqr xxwa cfy. psdc uqf "
"avrqc gefq pyat trac xwv taa wwd dv eas flcbq. vd trawm "
"vupq quw x decgqcwt, yq yafl vlqs yqklhq! snafq vml "
"lhvqpawr nqg_vfusr_ec_wawy qp fn wgawdgf.";

string decryptedText = decryptText(cipherText);

int position = 0;
bool afterFullStop = false;
bool replaceSpaces = false;
for (char c : decryptedText) {
if (!isalpha(c)) {
if (afterFullStop) {
cout << c;
} else {
if (c == '.') {
afterFullStop = true;
replaceSpaces = true;
} else if (c == '_') {
cout << ' ';
} else {
if (replaceSpaces) {
cout << " " << c;
replaceSpaces = false;
} else {
cout << c;
}
}
}
continue;
}
cout << c;
position++;
if (position == 5) {
position = 0;
}
}

return 0;
}
3 changes: 3 additions & 0 deletions Assignment 2/210479/readme1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
BREAKER OF THIS CODE WILL BE BLESSED BY THE SQUEAKY SPIRIT RESIDING IN THE HOLE GO AHEAD, AND FIND A WAY OF BREAKING THE SPELL ON HIM CAST BY THE EVIL JAFFAR. THE SPIRIT OF THE CAVE MAN IS ALWAYS WITH YOU. FIND THE MAGIC WAND THAT WILL LET YOU OUT OF THE CAVES. IT WOULD MAKE YOU A MAGICIAN, NO LESS THAN JAFFAR! SPEAK THE PASSWORD THE_MAGIC_OF_WAND TO GO THRHGTO.U