Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C++]First try of a XOR Encryptor

Newbie Spellweaver
Joined
Nov 28, 2006
Messages
56
Reaction score
0
Well here i go XD.

This is my second program, first was mailslot net sender.This is a simple and kinda inneficient XOR encryption program.

Basically encripts a file with a given key, and to recover the original file you must use the same key to process it again.

WARNING: It worked 10/10 times for me but im not completely sure so dont tryit on important files.

Another important info: When it processes a file the encrypted copy will have .crypt extension appended to the original file name , BUT when you process the ".crypt" file it will remove the ".crypt" from the path resulting in overwritting the original file, to avoid this either change name or move the file to another folder.

The .cript file is created in the same directory as the original file.


My english is crappy but i hope the info got clear ^_^.


I also have a problem, the exe is HUGE, 400+ kb uncompressed, and yes I disabled debugging information,any suggestions?


I would like you to post suggestions or bugs , the coments are greatly apreciated :D

Btw the rar file contains the executable and the source, its made in dev-Cpp.

PS:I forgot telling im ovbiously a newbie and requesting no flaming for my errors.
 

Attachments

You must be registered for see attachments list
Last edited:
Custom Title Activated
Loyal Member
Joined
Aug 8, 2004
Messages
3,892
Reaction score
20
A problem I encountered often too is that including some libraries, like std::cout, increases your executables filesize a lot. There is probably a way to avoid this, but I'm not aware of it.

As for overwriting, couldn't you add a warning asking the user if he wants to overwrite the file? :wink:
 
Divine Celestial
Loyal Member
Joined
Jul 7, 2004
Messages
853
Reaction score
5
lolwut

yes I disabled debugging information
O RLY? Then what's this crap?

Sprayz - [C++]First try of a XOR Encryptor - RaGEZONE Forums


A program of this sort should take no more than ~4KB at most. Indeed, you've exceeded that 100-fold.
its made in dev-Cpp
I see. Quite an inefficient compiler. MS C/C++ 12.x is a lot better IMHO.

Once you can get your compiler to produce a 1KB "Hello world!" messagebox, further techniques for size minimisation include NOT generating all the controls dynamically but using dialog box template instead, using the Win32 API in lieu of C file functions, and aligning the output PE with following options (in case of M$ linker):

Code:
/align:4096 /filealign:512 /merge:.rdata=.text /section:.text,EWR  /stub:{path to custom 64-byte stub} /subsystem:windows /machine:ix86 /entry:main

See the "Universal Network Terminal" I posted in another thread for example of doing this sort of optimisation.
 
Divine Celestial
Loyal Member
Joined
Jul 7, 2004
Messages
853
Reaction score
5
age

Excuse the doublepost, but I decided to see how big the resulting executable would be using my defaults.

It looks like my size prediction is perfect -- here's your 4KB executable, source, and the batch file I used to compile. I did not change the source code at all.
 

Attachments

You must be registered for see attachments list
Junior Spellweaver
Loyal Member
Joined
Mar 25, 2007
Messages
174
Reaction score
0
Re: lolwut

username1 said:
I see. Quite an inefficient compiler. MS C/C++ 12.x is a lot better IMHO.
This is the first time I have seen a mistake from you 'username1'. You should rewrite to say that MinGW is the compiler. Dev-Cpp is an IDE.

And the digital mars compilers are simply the best one can find.
For mroe information, please visit

Regards,
David Mackay
 
Divine Celestial
Loyal Member
Joined
Jul 7, 2004
Messages
853
Reaction score
5
Re: lolwut

This is the first time I have seen a mistake from you 'username1'. You should rewrite to say that MinGW is the compiler. Dev-Cpp is an IDE.

And the digital mars compilers are simply the best one can find.
For mroe information, please visit

Regards,
David Mackay
1. Same difference. No, MinGW is not a compiler either. GCC is the compiler.

2. Umm... no thx:
The Software is not generally available software. It has not undergone testing and may contain errors. The Software was not designed to operate after December 31, 1999. It may be incomplete and it may not function properly.
 
Junior Spellweaver
Loyal Member
Joined
Mar 25, 2007
Messages
174
Reaction score
0
Nonetheless, MinGW is more accurate than your saying dev-cpp is a compiler.
 
Last edited:
Junior Spellweaver
Joined
Apr 9, 2007
Messages
101
Reaction score
1
Re: age

Excuse the doublepost, but I decided to see how big the resulting executable would be using my defaults.

It looks like my size prediction is perfect -- here's your 4KB executable, source, and the batch file I used to compile. I did not change the source code at all.

WELL technically your Prediction Was WRONG it said 4.6kb not 4.0kb And You know that yourself.
 
Custom Title Activated
Loyal Member
Joined
Nov 19, 2003
Messages
1,174
Reaction score
0
4069B IS 4KB. A KB is 1024B, not 1000.

Yes, 2^10 = 1024, it is NOT 1000, however people simplify to 1000 because it is easier than 1024.

However, if you are talking scientifically with regards to SI units, 1 kB = 1000 bytes, because a lowercase k indicates kilo. It was then recommended to use an uppercase K, however this clashes with the SI unit for the Kelvin, and so it moved on to the Kibibyte, where 1024 bytes = 1 KiB
 
Divine Celestial
Loyal Member
Joined
Jul 7, 2004
Messages
853
Reaction score
5
sage

and so it moved on to the Kibibyte, where 1024 bytes = 1 KiB
...but that's a retarded unit, so it's generally agreed that 1KB = 1024B.

Also, look at the sizes of the intros in "4K intro" competitions. In fact, there was a monthly demoscene magazine titled "4096".
 
Junior Spellweaver
Loyal Member
Joined
Mar 25, 2007
Messages
174
Reaction score
0
age

Also note hard drive makers' stupidity in saying ' it has 9000 megabytes that's 9 gigabytes.'
 
Newbie Spellweaver
Joined
Feb 20, 2006
Messages
66
Reaction score
0
A problem I encountered often too is that including some libraries, like std::cout, increases your executables filesize a lot. There is probably a way to avoid this, but I'm not aware of it.

As for overwriting, couldn't you add a warning asking the user if he wants to overwrite the file? :wink:

put this underneath the includes...

Code:
 using namespace std;
 
Custom Title Activated
Loyal Member
Joined
Jun 28, 2007
Messages
2,986
Reaction score
3
XOR was one of the first encryption methods, its very basic. But can be cool if you're new ;)
 
Back
Top