This is a caesar encryption code, please help me with a code to reverse this operation (decrept it) in C++ string encrypt(string text, int s) { string result = ""; // traverse text for (int i=0;i


This is a caesar encryption code, please help me with a code to reverse this operation (decrept it)
in C++


string encrypt(string text, int s)
{
    string result = "";


    // traverse text
    for (int i=0;i<>
    {
        // apply transformation to each character
        // Encrypt Uppercase letters
        if (isupper(text[i]))
            result += char(int(text[i]+s-65)%26 +65);


    // Encrypt Lowercase letters
    else
        result += char(int(text[i]+s-97)%26 +97);
    }


    // Return the resulting string
    return result;
}


int main()
{
    string text;
    int s;

    cin>> text;
    cin >> s;
    cout < "text="" :="" "=""><>
    cout < "\nshift:="" "=""><>
    cout < "\ncipher:="" "="">< encrypt(text,="">
    return 0;
}



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here