Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main () {
- string str = "WTAADLDGASXCUDGBPIXDCHTRJGXIN";
- string dec = "WTAADLDGASXCUDGBPIXDCHTRJGXIN";
- int k = 0;
- for (int i=1; i<=26; i++) {
- k = i;
- for (int j=0; j<str.size(); j++) {
- if (str[j] + k > 'Z') {
- dec[j] = (str[j] + k) - 'Z' + 'A' - 1;
- } else {
- dec[j] = str[j] + k;
- }
- }
- cout << dec << '\n';
- }
- cout << '\n';
- k = 11;
- for (int i=0; i<str.size(); i++) {
- if (str[i] + k > 'Z') {
- dec[i] = (str[i] + k) - 'Z' + 'A' - 1;
- } else {
- dec[i] = str[i] + k;
- }
- }
- cout << "key K : " << k << '\n';
- cout << "plaintext : " << dec << '\n';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement