cin >> type;
cin.getline(type, 10);
That's not necessarily a problem. Chars form a mathematical group and so you can add a "larger number" (it'll be truncated modulo 256 (or equiv)) and then subtract it off again and get back to where you started.K.I.L.E.R said:Thanks. Sometimes I'm pretty hopeless.
I also found out ( by myself ) that I am assigning an int to a char.
Simon F said:That's not necessarily a problem. Chars form a mathematical group and so you can add a "larger number" (it'll be truncated modulo 256 (or equiv)) and then subtract it off again and get back to where you started.K.I.L.E.R said:Thanks. Sometimes I'm pretty hopeless.
I also found out ( by myself ) that I am assigning an int to a char.
BTW I wouldn't call this 'encryption' - it'd be almost as secure to use ROT-13
void encrypt(char text[10], int code);
//int decrypt();
void main()
{
int code=0, counter=0, option=0;
char text[10], answer=' ';
cout << "1. Encrypt" << endl;
cout << "2. Decrypt" << endl;
cout << "Will you decrypt or encrypt?";
cin >> option;
if(option == 1)
{
cout << "Enter some text: ";
cin >> text;
cout << "Enter code: ";
cin >> code;
encrypt(text, code);
}
if(option == 2)
{
}
}
void encrypt(char text[10], int code)
{
int counter=0, textLength=0;
char * enc;
//text encode
enc = text;
enc += code;
cout << enc << endl;
}
/*
int decrypt()
{
int code=0, counter=0, textLength=0;
char text[10], * enc=0;
}
*/
*enc=*enc+code
enc=text;
for (counter=0;counter<10;counter++)
{
*enc=*enc+code;
enc++;
}
It'll probably go over your head (like 99% of us) but the "Handbook of Cryptograpy" is on the net somewhere and it is excellentK.I.L.E.R said:The Amazon book I can't buy as I don't have any credit cards and converting money from Aus to US is a pain and I will end up paying more than double the suggested price. I'm not working either. :/
The second link is very enlightning.
Thanks
Captain Chickenpants said:It is actually aimed at the layman rather than computer geeks so is quite an easy read.
The point I was making that you should stop the encryption before the null character as encrypting it would potentially cause problems.
CC