Hello!

Please give an example of simple file encryption on delphi. It is necessary to encrypt some files. I decided to write a console program for this purpose, but I have never come across encryption.

So, at the entrance of the program must have a path to the file and key. Maybe something else missed? The output is a completely modified source file, without the possibility of reading, so that inside there was any abra-cadabra.

What type of files will need to be encrypted, obviously unknown, maybe jpg, and maybe exe or even py.

Conclusion: please, give some detailed source code with comments. Thank.

  • one
    As too many requests for a simple question, is not it? ;) XOR in your hands, the easiest way to encrypt - Alex Kapustin

3 answers 3

In general, it all depends on what complexity you need a cipher. The easiest way is to take a key and perform a XOR operation on a block by block (block size = key size). To decrypt, just execute XOR again, and the file will look the same. If something more complicated is needed, then there is also a large choice, for example, DES , 3DES , AES . Surely, there are ready libraries for them.

Here's another link, look, maybe it is: DCPcrypt - cryptography in Delphi .

    You can use the console utility 7zip. It can be included in the distribution of any programs. Just archive with a key instead of a password and do not complicate your life.

    As an option, if, of course, the result is important with minimal cost, and not the fact of writing;)