Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Encryption of data using Delphi

Posted on 1998-12-08
13
Medium Priority
?
357 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
[X]
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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

721 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