Page 3 of 5
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 3:44 pm
by Enrico Maria Giordano
James,
are you using latest xHarbour from SVN? Can I see your linker configuration file?
EMG
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 3:45 pm
by James Bott
Hunter,
Another question.
Do you know if the SIX driver automatically securely erases the original unencrypted DBF after it encrypts the file? Or, maybe it is encrypted in place (there is no new encrypted copy made)?
James
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 3:52 pm
by James Bott
Enrico,
are you using latest xHarbour from SVN? Can I see your linker configuration file?
I am using FWH 13.04 with xHarbour 1.2.3 Intl. (SimpLex) (Build 20130326). I don't know if xHarbour is the latest version.
Also using Borland 5.82.
ilink.cfg contains just this:
-L"c:\bcc582\lib"
I am using buildx.bat to build the test files.
Regards,
James
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 4:00 pm
by James Bott
Enrico,
Are you closing the file after encryption, then reopening it? I don't see that happening in your posted code. Maybe that is the issue.
James
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 4:15 pm
by Enrico Maria Giordano
James,
James Bott wrote:Enrico,
Are you closing the file after encryption, then reopening it? I don't see that happening in your posted code. Maybe that is the issue.
James
Tried. No changes. My current sample is:
Code: Select all | Expand
FUNCTION MAIN()
USE POLIZZE EXCLUSIVE
? SX_DBFENCRYPT( "EMAG" )
? SX_TABLETYPE()
INKEY( 0 )
RETURN NIL
I don't get the table POLIZZE.DBF encrypted. Can I see the sample you're using?
EMG
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 6:07 pm
by James Bott
Enrico,
This is working for me.
Code: Select all | Expand
#include "fivewin.ch"
FUNCTION MAIN()
local cPassword:="EHAB"
USE xcustomer EXCLUSIVE // unencrypted source
copy to customer
use
use customer // unencrptyed test file
? SX_DBFENCRYPT( cPassword )
// you must close and then reopen the file
use
use customer
? SX_TABLETYPE()
msgInfo(company,"Company - encrypted")
Sx_SetPass(cPassword)
msgInfo(company,"Company - decrypted")
use
RETURN NIL
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 6:13 pm
by Enrico Maria Giordano
James,
I found the culprit: it doesn't work with memo fields.

Can you confirm this?
EMG
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 6:50 pm
by TimStone
I'm very interested in this thread. However, we have some other considerations.
Many of us are now working with Harbour / MSVC 2012. Antonio has been encouraging people to move up to the newer compilers. The functions you are testing and working with are only valid with xHarbour.
James, you are using the old command style for testing these files, but how well will this work with data objects ?
Regarding ADS. That's a good option for those people who use the ADS Server. However, in my tests, I'm seeing much better performance on a network ( peer to peer ) when using DBFCDX instead of the ADS Local server. I have both available, so I technically could use the ADS option ( I think ), but then I may get performance hits from people using LOCAL.
I would appreciate if you would consider these issues as you discuss the options. I, also, am finding a need to encrypt my data. With all the "integration" I find people accessing my databases without caution. When they crash the databases, they tell the client its all my fault and I should repair them. It makes for rough situations.
Tim
Re: encrypting dbf files
Posted: Sun Sep 29, 2013 7:51 pm
by James Bott
Tim,
I see no reason it wouldn't work with data objects. We just need to subclass and add the password unlock and possibly a check to make sure the database is encrypted.
When time permits, I will test this to be certain.
James
Re: encrypting dbf files
Posted: Mon Sep 30, 2013 2:01 pm
by Enrico Maria Giordano
James,
did you check if the encrypting function works with memo fields? Maybe you missed my message above.
EMG
Re: encrypting dbf files
Posted: Mon Sep 30, 2013 2:38 pm
by James Bott
Enrico,
did you check if the encrypting function works with memo fields?
I will try to get to it today.
James
Re: encrypting dbf files
Posted: Tue Oct 01, 2013 5:58 am
by HunterEC
James:
I don't know the encryption algorithm that it uses. It encrypts the records over the old ones, no copy is made. Undelete tools will not recover the unencrypted data.
Enrico:
It does work with memo fields since I've been using it since 1996 in my production apps.
I suggest that you compile a small program that do the initial encryption using the SIX driver and then, and only then, the DBF header will have the 1st byte changed. Afterwards you can use the DBFCDX driver.
If you wish to email me one of your files, I'll happily will try your code with your DBFs.
Re: encrypting dbf files
Posted: Tue Oct 01, 2013 8:13 am
by Enrico Maria Giordano
HunterEC,
HunterEC wrote:Enrico:
It does work with memo fields since I've been using it since 1996 in my production apps.
Great!

HunterEC wrote:I suggest that you compile a small program that do the initial encryption using the SIX driver and then, and only then, the DBF header will have the 1st byte changed. Afterwards you can use the DBFCDX driver.
This is my
non-working sample. Please fix it. Use any tables with memo fields and xHarbour. Thank you!

Code: Select all | Expand
FUNCTION MAIN()
USE ANYTABLE EXCLUSIVE
? SX_DBFENCRYPT( "EMAG" )
? SX_TABLETYPE()
INKEY( 0 )
RETURN NIL
EMG
Re: encrypting dbf files
Posted: Tue Oct 01, 2013 3:14 pm
by James Bott
Hunter,
The following code is working fine for me
without using the SIX RDD. I can confirm that the file is encrypted.
When I attempt to use either VIA SIXCDX or EXTERNAL SIXCDX I get this error:
Error: Unresolved external '_HB_FUN_SIXCDX' referenced
Any ideas? Do we really need this? Is there an include file that I am supposed to be referencing? Do you have a sample program you can share?
James
Code: Select all | Expand
// Test Six lib's DBF encryption
#include "fivewin.ch"
FUNCTION MAIN()
use xcustomer exclusive // source file
copy to customer // working file
use
USE customer EXCLUSIVE
? SX_DBFENCRYPT( "EMAG" ) // returns .t.
? SX_TABLETYPE() // returns 2
RETURN NIL
Re: encrypting dbf files
Posted: Tue Oct 01, 2013 3:29 pm
by Enrico Maria Giordano
James,
James Bott wrote:The following code is working fine for me without using the SIX RDD.
As far as I know, SIXCDX is included in xHarbour's DBFCDX.
EMG