From the August 2010 Issue of Prestwood eMag
Delphi for Win32:
Delphi: Encryption of data fields
Posted 5/19/2003 on 5/19/2003
Take Away: This article discusses the reasons and methods for encrypting data fields in Delphi.


Keeping sensitive data from prying eyes is an issue that Delphi developers often face. Even if you use database encryption methods, there are often times when you need to apply a second level of protection on your data fields.

With desktop databases, such as Paradox, Access, or Advantage Database, the data values stored in the data files can often be viewed with most file editors. Enabling database encryption on your tables can prevent casual access to your data, but this method is only as effective as the user security you implement on the database.

To keep authorized database users out of your sensitive data, such as passwords or credit card numbers, you need to implement a second level of security on the data fields themselves. In Delphi, this can be accomplished by adding data filtering to the fields you wish to encrypt, and using an encryption algorithm to alter the field values.

There are many data encryption algorithms available in the public domain that you can use, such as Blowfish, DES, RC2, RC4, Ice, CAST, or Serpent, as well as many others. There are many Delphi libraries and components that implement the algorithms you select.

In Delphi, you can add encryption filtering to a data field through the GetText and SetText TField events. These events allow you to convert the string value of a field when it is read from or written to the database.

One FREE component suite we use here at Prestwood Software that we found to be both well-written and easy to implement is the DCPcrypt Cryptographic Component Library by David Barton. The URL to his version 2.2 beta release is at


Share a thought or comment...
Comment 1 of 1

hello world

Posted 6/4/2015
KB Post Contributed By Scott Wehrly:

Scott Wehrly is currently working on .Net web applications for the gaming industry. Scott is a former employee of Prestwood Software (he was a Development Manager). Scott's specialties include C#, ASP.Net, MSSQL Server 2005, Delphi, SQL databases, C++, C, and Windows programming in general. When time allows, he participates in this online community.

Visit Profile For service: 916-726-5675
Copyright (C) Prestwood IT Solutions.
All Rights Reserved.
Printed 5/12/2021