Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- string danny_code(string);
- int main() {
- string str;
- cout << "Enter sentence to encrypt: ";
- getline(cin, str);
- string encrypted = danny_code(str);
- cout << "\n\nEncrypted: " << danny_code(str);
- cout << "\n\nDecrypted: " << danny_code(encrypted);
- return 0;
- }
- string danny_code(string str) {
- char key[5] = { 'D', 'A', 'N', 'N', 'Y' };
- string result = str;
- for (size_t i = 0; i < str.length(); i++)
- result[i] = str[i] ^ key[i % (sizeof(key) / sizeof(char))];
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement