I've been playing around with c++ a bit, and made a "encrypt"-"decrypt" thing.
Just basically taking the int value of the letters and adding x to them - becomming a new character/letter.

This is the code where it asks the user for an input:

void decryptonise()
{
    string text2;
    cout <<"What would you like to \"decryptonise\"?:\n";
     cin.get();   getline(cin,text2); //I have this cin.get because the user inputs 2 //to chose decrypt - enter - without it, it would take that enter as input for the //getline

  cout <<"\nDecrypted text:\n";

for(int i=0; i<text2.size(); i++)
    {
        int coop2 = text2[i];

        if(i%2==0)
        {
            cout <<(char)(coop2-33);
        }
        else
        {
            cout <<(char) (coop2-18);
        }
    }
    cout<<endl<<"\nPress [ENTER] to go back to the menu.";cin.get();
}

If I paste a text that is longer than a row, it will automatically take that row, decrypt it, and jump out of the function.

How can I fix it?

Here is the whole thing:
http://pastebin.com/7EXASrb9

As far as I can tell it should read as much as much as you type untill it hits a carriage return. I wrote a little test to show this

#include <iostream>
#include <string>

using namespace std;

int main()
{
	string temp;
	cout << "Enter a big line of text: ";
	getline(cin, temp);
	cout << "\nI got: " << temp;
	cin.get();
	return 0;
}

I typed in 5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555222222222222
and got the same thing back.

Edited 5 Years Ago by NathanOliver: n/a

As far as I can tell it should read as much as much as you type untill it hits a carriage return. I wrote a little test to show this

#include <iostream>
#include <string>

using namespace std;

int main()
{
	string temp;
	cout << "Enter a big line of text: ";
	getline(cin, temp);
	cout << "\nI got: " << temp;
	cin.get();
	return 0;
}

I typed in 5555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555 555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555222222222222
and got the same thing back.

Yes, but try copying that, and pasting it.
That's where I'm having problems.
I can type in multiple lines, it encrypts it. But if I try to paste it in, it fucks up

I was still able to after pasting it in. I even used your code and I was still able to paste it it and get the whole line back. IDK what is going on. What OS are you using.

I was still able to after pasting it in. I even used your code and I was still able to paste it it and get the whole line back. IDK what is going on. What OS are you using.

OK.. weird..
I tried your lines (the 5:s) and it worked...
This is what I was trying to decrypt:

züû2ÉÇÜ2ësùwAåëwAwÖsÄ2òüÄüôüÿQAïÉçAuÉçìvAvÉ2èåAâû{ä}ìïM2àüåàÅ9ò2ÄsòååäA{ç2Üüû2çs
è~AïÉçAàé{à@A\ûàò2àüAëësò2û2äsÅ2Æçèuî~Ü>AvÉÇHåAuéäå2étÉçò2òzå2ësôvAüÅwö2Iåé}èÇê2
ì{îwADQ=A¦èÇAåÉ2öüìêå;

No idea what it does what it does...


Oh and windows by the way. Windows vista.
A friend with windows 7 tried it, same problem.

What you have posted here has carraige returns in it. I put it note pad and made it all one line and i was able to paste it into the console. I'm attaching the .txt file I used.

Attachments
z22swAwAws2QAAuvAv2A{}M292sA{22s~AA{@A\2As22s2u~>AvHAu2t2z2svAw2I}2{wADQ=AA2;
This article has been dead for over six months. Start a new discussion instead.