Solved

HELP - Encryption/Decryption source code

Posted on 1997-11-09
8
310 Views
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.
0
Comment
Question by:mineiro
8 Comments
 
LVL 5

Expert Comment

by:yonat
Comment Utility
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.
0
 

Author Comment

by:mineiro
Comment Utility
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
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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.  

0
 
LVL 7

Accepted Solution

by:
faster earned 330 total points
Comment Utility
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.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Expert Comment

by:yonat
Comment Utility
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.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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?
0
 
LVL 2

Expert Comment

by:wpinto
Comment Utility
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
0
 
LVL 5

Expert Comment

by:yonat
Comment Utility
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.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now