views:

519

answers:

3

Hi i would like to know best encryption technique for text file encryption and ecryption.

My Scenario:

I have software having two type of users Administartor and Operators. Our requirement is to encrypt text file when Administrator enter data using GUI and save it. That encrypted file would be input for Operator and they just need to select it and use that file. Here file should be automatically decrypt data for further calculation when Operator select those files.

Please help me which encryption/ decryption technique should i use?

+12  A: 

A golden rule when doing crypto is to understand that cryptography as a whole it is very difficult.

There are a multitude of different approaches/algorithms to choose from, and no single algorithm/method can be said to be the best one. It all depends on your needs and possibilities to affect application distribution etc.

An example of a potentially problematic situation is that in your scenario the decryption "key" needs to be distributed with the application(s) and might make it insecure. This is generally referred to as the "Key Distribution" problem.

A good place to start reading about crypto is http://en.wikipedia.org/wiki/Cryptography.

As for ready made stuff for Delphi there are a few good packages available:

Torry's pages also has a long list of components:

I strongly recommend you use some of the existing implementations and not start to do your own, since creating a secure working crypto algo is very very difficult.

K.Sandell
DEC (The Delphi Encryption Compendium) is very powerful. Good recommendation!
Sebastian P.R. Gingter
Windows itself provides very good implementation for various cryptographic algorithms using Windows CryptoAPI.I recommend you using CryptoAPI, or write a wrapper class around CryptoAPI functions, and use them in your code.
vcldeveloper
Thanks, for providing me such a good start
Hemant Kothiyal
+2  A: 

When moving an encryptet message from place/appliction to another, one of the problems you have to consider is where to store the encryption/decryption keys.

As i se your scenario, it seems like it is build in your applications. If so remember to use al sorts of tricks to hide it: Password strings should be split in several bits and onlys appended in a protected memoryspace, that has to be marked as non-pageable (else password could be seen in the pagefile).
The same rules for the content that is unencrypted (the text-file). It's best that it never is saved (even temporaly) unencrypted to disk. If it is saved, the overwrite the date with garbage after use, before deleting it.

Another approch (specialy if you already use compression components), is that the (text) file, can be compressed using a password.

BennyBechDk
+3  A: 

Truthfully, there is no "best" technique. It basically depends on the sensitivity of the data you're trying to protect and the number of people who might access this data. What might be "best" for me might be pure overkill for your project. In your case, you could use any dual-key encryption method. Or asymmetric key. Basically, the administrator has one key and the operator has the other. The administrator can then encrypt files, but he won't be able to decrypt them again, unless he has an operator key. The operator can decrypt the file and -if need be- encrypt a file that only an administrator can access. (Asymmetrical keys encrypt in both ways.)

There are several solutions that make use of these asymmetrical keys. The one that would be best is the one that you could add to your project in the easiest way while still offering enough protection for your needs.

Building your own asymmetrical key algorithm is possible too, if you're a real Math Wizard. The calculations are complex and involve extremely high prime numbers in most solutions. As K. Sandell said, find a good, existing solution that matches your needs in the best way.

Workshop Alex