Solved

Encryption of data using Delphi

Posted on 1998-12-08
13
339 Views
Last Modified: 2010-04-04
Howdy

I'll get straight to the point.
For a program I'm making, I need to encrypt data which is stored in binary format in a file.

I know very little abouyt encrypting data in Delphi. Ciuld somebody PLEASE guide me as to how to go about doing something like this, or show me a site where i can learn!

Thanx
0
Comment
Question by:X_Kalibur
  • 6
  • 5
  • 2
13 Comments
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350021
Look at the Delphi Super Page (http://sunsite.icm.edu.pl/delphi/), there are a bunch of them there. Go to the search page and enter encryption for the search criteria.

Cheers,

Raymond.
0
 
LVL 2

Expert Comment

by:Thaddy
ID: 1350022
0
 
LVL 1

Author Comment

by:X_Kalibur
ID: 1350023
rwilson:

Its not that your answer was wrong, but I didnt express what I wanted clearly..Sorry!

What I'm looking for, are just basic method of encryption, so that the file cant be hacked. I'm not really looking for hardcore algorithms to give me nightmares!
If you can help me, I'd really appreciate it!

thanx

- x
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1350024
OK - a simple and effective algorithm for preventing someone hacking a file!

Step1. Take the file and calculate the crc32 checksum for it (there are crc32 sources left, right and center on the web - do an Altavista search and pick one that fits into your system best.)

Step2. XOR that 32 bit number with your phone number (or some other number)

Step3. Store that number with the file (perhaps at the beginning) or as a registry entry.

Step4. When you come to use the file calculate the CRC32 XO it with your number and check it against the previously calculated value - if its different the file has been tampered with.

Cheers,

Raymond.


0
 
LVL 1

Author Comment

by:X_Kalibur
ID: 1350025
Thanx.

Thats basically what i wanted to know... Are there any other ways of encrypting stuff, or do you just XOR it?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350026
There are thousands of ways of doing it! Any method that alters information into unreadable form and can return it to its original condition could be called encryption (perhaps the oldest and best known is the Ceasar cipher where you rotate the letters of the alphabet by a number of chars (eg: a shift of 2 means a--> c, b--> d etc) Perhaps the newest and potentially strongest are called alliptic curve ciphers - though there is a current argument regarding their strength.

Compressing data is an effective form of encryption is sother parties do not know how to decompress it!

Basically you pick what suits your needs best.

Cheers,

Raymond.

0
 
LVL 1

Author Comment

by:X_Kalibur
ID: 1350027
rwilson:

Is there a way, that I can directly XOR (or perform any other boolena operation) a string of text. Because I tried to directly XOR the string with a key, and it only likes integer values. So I "val"ed the string, and then XORed the val, and the result I got was my key! Could you possibly show me a way to change the string so that it looks reasonably encrypted (Other than a Caesars Cypher).
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350028
XOR each char individually eg:

Function XORit(Source, key : String) : String;
var,
  i : integer;

begin
  setlength(result, length(source));
  for I := 1 to length(source) do
    result[i] := chr(ord(source[i]) XOR ord(key[i mod length(key) + 1]));
end;

Cheers,

Raymond.  
0
 
LVL 2

Expert Comment

by:Thaddy
ID: 1350029
xor'ing is a very easy to break encryption algoritm. Anyone with two years math can do it.
I cannot reccommend xoring for any serious encryption, especially not if you use crc32 with it, since crc32 is designed to EASILY recreate an original file, because it can be used and was designed for fault tolerance.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350030
Thaddy: I agree, XORing is not a strong encryption, X_Kalibur was really looking for a simple means of making it hard for someone to modify a file. Hiding the actual contents didn't seem terribly important.

Cheers,

Raymond
0
 
LVL 1

Author Comment

by:X_Kalibur
ID: 1350031
rwilson:

Actually, I'm sorry if I didnt make this clear before, but the whole idea of encrypting the file is so that it cant be read from any external viewer!

thanks

 -x
0
 
LVL 1

Author Comment

by:X_Kalibur
ID: 1350032
*Continued*

Are there other ways then to simply hide the contents?
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1350033
OK - let me make this clear:

You ARE hiding the contents of the file from an external viewer. The problem is that XORing is not a strong form of encryption (though, if the attacker cannot perform a chosen plaintext attack it can get pretty messy trying to break!)

As I mentioned in a previous comment there are thousands of ways to encrypt information. You need to decide why you are encrypting it --> This determines how much protection you require which will then push to towards certain classes of encryption methods.

Cheers,

Raymond.

0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

830 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