-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathmain.cpp
40 lines (32 loc) · 1.02 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <bits/stdc++.h>
using namespace std;
void author_list() {
// contributor list
string contributor_names[] = { "Manish", "Ayushman" };// add your name here
int cnt = sizeof(contributor_names) / sizeof(contributor_names[0]);
cout << "\n\n-:: Authors ::-\n";
for (int i = 0; i < cnt; i++) {
cout << " ";
for (char c : contributor_names[i]) {
cout << c;
}
cout << endl;
}
}
void secret_message(const char* encoded, int key) {
int len = strlen(encoded);
char decoded[len + 1]; // initalising char array
for (int i = 0; i < len; i++) {
decoded[i] = encoded[i] ^ key;
}
decoded[len] = '\0'; // null termination marks end of string
printf("Secret Message: %s\n", decoded);
}
int main() {
const char encoded_message[] = { 'K', 'C', 'D', 'C', 'M', 'V', 'N', 'C', 'Q', 'J', '\0' };
int key = 42;
printf("Decoding secret message...\n");
secret_message(encoded_message, key);
author_list();
return 0;
}