How to encrypt Visual FoxPro .dbf files (115476)



The information in this article applies to:

  • Microsoft Visual FoxPro for Windows 3.0
  • Microsoft Visual FoxPro for Windows 6.0
  • Microsoft Visual FoxPro for Windows 7.0
  • Microsoft Visual FoxPro 8.0
  • Microsoft Visual FoxPro 9.0 Professional Edition

This article was previously published under Q115476

SUMMARY

Microsoft Visual FoxPro can encrypt table (.dbf) ) files by building them into an encrypted .exe file. However, when the .exe file is run, the table files cannot be modified.

To work around this behavior, you can use several third-party products to encrypt FoxPro table files while allowing the data to be modified. You can also write a program to encrypt Visual FoxPro table files.

MORE INFORMATION

Encryption prevents users from accessing .dbf files directly. It works by changing the file so it is not recognizable as a .dbf file. Visual FoxPro cannot use the .dbf file again until it is decrypted. Following are some of the ways you can encrypt .dbf files in Visual FoxPro.

Using Visual FoxPro to encrypt .dbfs

If a .dbf file does not need to be modified, you can add it to your project list and not mark it for exclusion. When you build an encrypted .exe file, the .dbf data will be included in it. You do not need to physically copy the .dbf file to the subdirectory where the .exe file will be found. When you run the .exe file, the .dbf information can be accessed, but it cannot be changed. Decryption of the .dbf file is automatic when the .exe file is run.

Beginning in Visual FoxPro 7.0, you can use the Crypt.vcx Visual FoxPro Foundation Class to encrypt data. The cryptapi class that is located in the ...\Ffc\_Crypt.vcx foundation class library provides access to the Windows Crypto API routines so you can encrypt strings, data, or files in your Visual FoxPro Applications. For more information on the _Crypt.vcx and the _crytapi class, see search the Help file for "_Crypt.vcx."

Third-party products to encrypt .dbf files

NetLib
Communication Horizons

http://www.netlib.com

Cryptor
Xitech, Inc.

The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Writing a program to encrypt .dbf files

Many Visual FoxPro reference books contain sample code for different methods of encrypting and decrypting database files.

For examples, see these books:

"FoxPro 2.0 Power Tools," Malcolm C. Rubel, pages 938-942, Bantam Books, 1991, ISBN 0-553-35294-6

"Tom Rettig's FoxPro Handbook," Tom Rettig, pages 622-625, Bantam Books, 1990, ISBN 0-553-34937-6

"FoxPro 2.5 Advanced Developer's Handbook", Pat Adams and Jordan Powell, pages 222-228, Brady Publishing, 1993, ISBN 0-13-325341-4

Modification Type:MajorLast Reviewed:2/16/2005
Keywords:kb3rdparty KB115476