We help IT Professionals succeed at work.

HELP - Encryption/Decryption source code

mineiro asked
Medium Priority
Last Modified: 2008-03-06
I need a source code of a program wich reads a file.txt and transforms it in an output text file with the same data, but
encrypted!!!!!I WILL PAY 330 POINTS.
Watch Question

There are many cryptographic libraries that do that. I use crypto++ from http://www.eskimo.com/~weidai/cryptlib.html

To encrypt a file using crypto++, write:

void EncryptFile(const char *fin, const char *fout, const char
    FileSource f(fin, true, new DefaultEncryptor(passwd,
        new FileSink(fout)));

And to decrypt:

void DecryptFile(const char *fin, const char *fout, const char
    FileSource f(fin, false, new DefaultDecryptor(passwd,
        new FileSink(fout)));

There are many other libraries available, as are many source files. If you need more info, please add a comment, and I'll be happy to help.


Sorry, but I need a source code that do what i  want using the libraries of tc++, because i can't use another libraries. I've got to use the fopen...etc.
Thank you, and please answer me NOW!!!!!!!!!!!!!!!!!!!!!!!!!1

Most of the standard algorythms for encryption are a little complex.  However, they provide security in cases where the encrypting algorythm is not kept a secret.  If you (or a limited group of programmers) will be the only ones who will know the algorythm, then descent security can be obtained by a applying a combination of a few simple algorythms, such as rolling XOR, bit scramble, or substitution.  These encryptions are fast and easy to write.  They are tough enough to break that only a dedicated person could break them.  A couple hours of work trying to break them probably not yield results.  However, the encryption is not as robust as the more standard techniques.  And there are a few little tricks that can be applied to make this even more secure.

I can provide more details if this sore of method would work for you.  However, as I said before, this technique assumes that the encrypting algorithm (code) will be kept a secret.  Many people consider this to be too dangerous.  

Normally people use DES for large data encryption, there are also other algorithms.

Actually this kind of code is in wide spread.  I have two versions of the source code implementing DES.  The problem is that DES is protected by US export law.

I suggest you get the algorithm from some books (for example, "Network Security") and implement yourself, it not that complex.  If you choose IDEA (another algorithm like DES), it is even easier to implement.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

crypto++ is portable. Use can use it with Turbo C++. The classes FileSource and FileSink are just wrappers for fstream.

crypto++ contains source code for DES, RC5 and many other encryption algorithms. You can use them as-is, or using the convenient wrappers, which will make your code much simpler.

But can crypto++ be used in a product exported from the US?  Can crypto itself be exported from the US?  Or was it written outside the US?  Or does anyone care becuase the law isn't inforcable anyway?

Hi mineiro,

Some more sources for DES source code:

The Standard Data Encryption Algorithm, Harry Katzan Jr, Petrocelli Books, 1977 ISBN 0-89433-016-0 (APL).

Computer Networks, Andrew S. Tanenbaum, Prentice Hall (both editions; second edition is ISBN 0-13-162959-X). (Pascal)

Numerical Recipes, William H. Press et al, Cambridge University Press. (Fortran and Pascal version is ISBN 0-521-30811-9. Also in Numerical Recipes in C).

UNIX System Security, Wood and Kachan, Hayden. ISBN 0-8104-6267-2.

Cryptography: An Introduction to Computer Security, Seberry and Pieprzyk, Prentice Hall Australia. (C)

Mathematical Cryptology for Computer Scientists and Mathematicians, Wayne Patterson, Rowman and Littlefield, 1987. ISBN 0-8476-7438-X.

Introduction to the Analysis of the Data Encryption Standard (DES), Wayne G. Barker, ISBN 0-89412-169-3 (soft cover), 0-89412-170-7 (library bound), 1991, Aegean Park Press, Appendix G. (Basic, of all things).


crypto++ was developed in the US and donated to the public domain. Some awful criminals uploaded it to crypto sites around the world ;-). In the US, it is legal to use it. Outside the US, it depends on the local law.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.