Decrypt the Message string by using Key Phrases


#include <bits/stdc++.h>

using namespace std;

  

string Decryption(string s, string key)

{

  

    

    

    vector<string> msg;

  

    

    

    vector<string> ans;

  

    istringstream s1(s);

    istringstream s2(key);

  

    string word;

  

    while (s1 >> word) {

  

        

        

        

        msg.push_back(word);

    }

  

    while (s2 >> word) {

  

        

        

        

        ans.push_back(word);

    }

  

    

    

    

    

    for (int i = 0; i < msg.size(); i++) {

  

        

        

        

        string message = msg[i];

  

        

        

        

        string hint = ans[msg.size() - i - 1];

        int value = hint.size();

  

        

        

        if (value % 2) {

            for (int i = 0; i < message.size(); i++) {

  

                

                

                

                

                if ((message[i] - 0) + value > 122) {

  

                    

                    

                    

                    

                    

                    int val = message[i] + value - 122;

                    int temp = 96 + val;

                    message[i] = (char)temp;

                }

                else {

  

                    

                    

                    

                    

                    int val = message[i] + value;

                    message[i] = (char)val;

                }

            }

        }

  

        

        

        else {

  

            

            

            

            

            for (int i = 0; i < message.size(); i++) {

                if ((message[i] - 0) - value < 97) {

  

                    

                    

                    

                    

                    

                    

                    int val = message[i] - 96 - value;

                    int temp = 122 + val;

                    message[i] = (char)temp;

                }

                else {

  

                    

                    

                    

                    

                    int val = message[i] - value;

                    message[i] = (char)val;

                }

            }

        }

  

        

        

        

        msg[i] = message;

    }

  

    

    

    string f_ans = "";

    for (int i = 0; i < msg.size(); i++) {

        f_ans += msg[i];

        if (i < msg.size() - 1)

            f_ans += ' ';

    }

    return f_ans;

}

  

int main()

{

    string Message = "qiix gz clro";

    string Key = "one orange ball";

  

    

    cout << Decryption(Message, Key);

  

    return 0;

}


#include <bits/stdc++.h>

using namespace std;

  

string Decryption(string s, string key)

{

  

    

    

    vector<string> msg;

  

    

    

    vector<string> ans;

  

    istringstream s1(s);

    istringstream s2(key);

  

    string word;

  

    while (s1 >> word) {

  

        

        

        

        msg.push_back(word);

    }

  

    while (s2 >> word) {

  

        

        

        

        ans.push_back(word);

    }

  

    

    

    

    

    for (int i = 0; i < msg.size(); i++) {

  

        

        

        

        string message = msg[i];

  

        

        

        

        string hint = ans[msg.size() - i - 1];

        int value = hint.size();

  

        

        

        if (value % 2) {

            for (int i = 0; i < message.size(); i++) {

  

                

                

                

                

                if ((message[i] - 0) + value > 122) {

  

                    

                    

                    

                    

                    

                    int val = message[i] + value - 122;

                    int temp = 96 + val;

                    message[i] = (char)temp;

                }

                else {

  

                    

                    

                    

                    

                    int val = message[i] + value;

                    message[i] = (char)val;

                }

            }

        }

  

        

        

        else {

  

            

            

            

            

            for (int i = 0; i < message.size(); i++) {

                if ((message[i] - 0) - value < 97) {

  

                    

                    

                    

                    

                    

                    

                    int val = message[i] - 96 - value;

                    int temp = 122 + val;

                    message[i] = (char)temp;

                }

                else {

  

                    

                    

                    

                    

                    int val = message[i] - value;

                    message[i] = (char)val;

                }

            }

        }

  

        

        

        

        msg[i] = message;

    }

  

    

    

    string f_ans = "";

    for (int i = 0; i < msg.size(); i++) {

        f_ans += msg[i];

        if (i < msg.size() - 1)

            f_ans += ' ';

    }

    return f_ans;

}

  

int main()

{

    string Message = "qiix gz clro";

    string Key = "one orange ball";

  

    

    cout << Decryption(Message, Key);

  

    return 0;

}

FOLLOW US ON GOOGLE NEWS

Read original article here

Denial of responsibility! Techno Blender is an automatic aggregator of the all world’s media. In each content, the hyperlink to the primary source is specified. All trademarks belong to their rightful owners, all materials to their authors. If you are the owner of the content and do not want us to publish your materials, please contact us by email – admin@technoblender.com. The content will be deleted within 24 hours.
decryptKeyLatestMessagephrasesstringTechUpdates
Comments (0)
Add Comment