Solved

Encryption of data using Delphi

Posted on 1998-12-08
13
337 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
ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 152
Using idhttp to login to instagram 2 90
find a node in VST 2 69
Delphi IDE crash without error message ... 7 91
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

810 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