All pastes #75200 Raw Edit

Something

public cpp v1 · immutable
#75200 ·published 2006-06-29 22:17 UTC
rendered paste body
#include <iostream>#include <string>using namespace std;int main (int argc, char** argv) {    int x = 13;    string text;    char a;    if (argc >= 2) x = atoi(argv[1]);    if (!(x >=0 && x < 26)) exit(1);    getline(cin, text);    for (int i = text.length() - 1; i >=0; i--) {        a = text[i];        if (0x41 <= (a & ~0x20) && (a & ~0x20) <= 0x5A)                 // Convert to uppercase and check for range of uppercase ASCII chars            a = ((a & ~0xE0) + x - 1) % 26 + 1 + (a & 0xE0);            // Take the last five bits (upon which the alphabet in ASCII runs from 00001 to 11010, regardless of case) and convert to 0-based by subtracting one, then rotate by adding rotOffset and using % 26, then add the one back in to return to a valid ending 5 bits to the ASCII code for the new character, which is completed by adding back in the first three bits from the encrypted character, which incidentally preserves case        text[i] = a;    }    cout << text;    return 0;}