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
Solved

HELP - Encryption/Decryption source code

Posted on 1997-11-09
8
315 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
ID: 1172844
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
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
0
 
LVL 22

Expert Comment

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

0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 7

Accepted Solution

by:
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.
0
 
LVL 5

Expert Comment

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

Expert Comment

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

Expert Comment

by:wpinto
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).

Wilfred
0
 
LVL 5

Expert Comment

by:yonat
ID: 1172851
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 Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Suggested Solutions

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 (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

840 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