Very Basic Encryption of Text File

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
I'm trying to store an IP address, and a username and password to that FTP site in a file on disk that will be read by a program of mine. Security isn't very important, but I want something better than storing in plain text.

Basically simpler is better, how I can do some kind of basic encryption when I write the file, and then somehow be able to extract the info when needed (from within my program only, doesn't need to actually decrypt the file on disk)?

Thanks everyone.

PS - VC++ 6.0, WinXP
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
xor every character with a key, xor again to get it back. hey you wanted simple & basic :laugh:
 

bersl2

Golden Member
Aug 2, 2004
1,617
0
0
Crypto++

Well, yeah, you could XOR. It doesn't get more basic than that. I figured you meant a bit more than that. It's pretty damn easy to dictionary it. Hell, you might as well ROT-13 it.
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: CaptainKahuna
Originally posted by: dighn
xor every character with a key, xor again to get it back. hey you wanted simple & basic :laugh:

That's actually fine with me.

Can I have some more details?

char encrypted = original ^ key;
char decrypted = encrypted ^ key;

key can be any value

rather useless of course but if all you want is for it to be no plain text...
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
If you're not going to do it well, you might as well not do it. If your tool becomes even remotely popular someone will reverse engineer the 'encryption' you're using.
 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
Originally posted by: Nothinman
If you're not going to do it well, you might as well not do it. If your tool becomes even remotely popular someone will reverse engineer the 'encryption' you're using.

Any ideas then for easy to implement encryption for a single 3 line txt file :)
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Blowfish encryption free C++ source is out there (Google), it's strong encryption and fairly easy to use.

If not, xor is very slightly better than plain text but if any users care about security then expect to get complaints.
 

CaptainKahuna

Platinum Member
May 19, 2002
2,228
0
0
www.billda.com
I've implemented XOR as below, the program compiles, but it crashes when I run it. What am I doing wrong? All the strings are filled with cin before they are accessed or assinged, I only included that relevant parts though.

// definitions
string string1;
string string2;
string string3;

string string1CRYPT = string1;
string string2CRYPT = string2;
string string3CRYPT = string3;

const char KEY = 'q';

// encrypt strings with xor encryption
for (i = 0;i < string1.length(); i++)
{
string1CRYPT = string1 ^ KEY;
}

for (i = 0;i < string2.length(); i++)
{
string2CRYPT = string2 ^ KEY;
}

for (i = 0;i < string3.length(); i++)
{
string3CRYPT = string3 ^ KEY;
}


for (i = 0;i < string1.length(); i++)
{
string1 = string1 ^ KEY;
}

for (i = 0;i < string2.length(); i++)
{
string2 = string2 ^ KEY;
}

for (i = 0;i < string3.length(); i++)
{
string3 = string3 ^ KEY;
}