• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 364
  • Last Modified:

Encryption of data using Delphi

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
X_Kalibur
Asked:
X_Kalibur
  • 6
  • 5
  • 2
1 Solution
 
rwilson032697Commented:
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
 
ThaddyCommented:
0
 
X_KaliburAuthor Commented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
rwilson032697Commented:
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
 
X_KaliburAuthor Commented:
Thanx.

Thats basically what i wanted to know... Are there any other ways of encrypting stuff, or do you just XOR it?
0
 
rwilson032697Commented:
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
 
X_KaliburAuthor Commented:
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
 
rwilson032697Commented:
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
 
ThaddyCommented:
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
 
rwilson032697Commented:
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
 
X_KaliburAuthor Commented:
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
 
X_KaliburAuthor Commented:
*Continued*

Are there other ways then to simply hide the contents?
0
 
rwilson032697Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 6
  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now