HELP - Encryption/Decryption source code

Posted on 1997-11-09
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.
Question by:mineiro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

ID: 1172844
There are many cryptographic libraries that do that. I use crypto++ from

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.

Author Comment

ID: 1172845
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
LVL 22

Expert Comment

ID: 1172846
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.  

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

faster earned 330 total points
ID: 1172847
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.

Expert Comment

ID: 1172848
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.
LVL 22

Expert Comment

ID: 1172849
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?

Expert Comment

ID: 1172850
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).


Expert Comment

ID: 1172851
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.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

690 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question