Link to home
Start Free TrialLog in
Avatar of mineiro
mineiro

asked on

HELP - Encryption/Decryption source code

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.
Avatar of yonat
yonat

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
*passwd)
{
    FileSource f(fin, true, new DefaultEncryptor(passwd,
        new FileSink(fout)));
}

And to decrypt:

void DecryptFile(const char *fin, const char *fout, const char
*passwd)
{
    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.
Avatar of mineiro

ASKER

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.  

ASKER CERTIFIED SOLUTION
Avatar of faster
faster

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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).

Wilfred
nietod,
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.