encrypting dbf files

Re: encrypting dbf files

Postby James Bott » Wed Sep 25, 2013 8:30 pm

Jeff,

I use the free ADS encryption. It encrypts the entire file.


So does the Six RDD. I was responding to Jack's request to just encrypt a couple of fields. I don't know if the Six RDD will do this, but I don't know why it would be useful either.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encrypting dbf files

Postby James Bott » Wed Sep 25, 2013 8:40 pm

Hunter,

I just reread this:

(x)Harbour supports three functions to handle encryption / decryption transparently:
1. Sx_DBFencrypt (cPassword) - encrypts all records in database file.
2. Sx_DBFdecrypt () - decrypts all records in database file.


This leaves me wondering, are there functions to encrypt and decrypt a record (or field)? I can't see how decrypting an entire DBF would be practical in an application.

Are the SX functions documented somewhere online, or is there a downloadable manual?

What would be really nice is just something like SET ENCRYPTION ON, then using the database as you normally would. Is this possible? Or, better yet, if the Six RDD could automatically detect if the file was encrypted, and then automatically (and transparently) encrypt and decrypt the data as needed. Now that would that be nice!

However, if we had the capability to encrypt and decrypt records, then we could build the encryption/decryption into a database class so it would all be transparent.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encrypting dbf files

Postby ADutheil » Thu Sep 26, 2013 1:46 am

Most of the SX functions are documented in the SIX3.NG. It´s a 500kb file. I have it but I´m not sure it´s allowed to publicly share it. If yes I can upload it to my FTP server, if not I can send as email attachment. Just let me know.
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: encrypting dbf files

Postby Enrico Maria Giordano » Fri Sep 27, 2013 12:05 pm

James,

James Bott wrote:What would be really nice is just something like SET ENCRYPTION ON, then using the database as you normally would. Is this possible? Or, better yet, if the Six RDD could automatically detect if the file was encrypted, and then automatically (and transparently) encrypt and decrypt the data as needed. Now that would that be nice!


Please have a look at Marco's message at the start of this thread. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: encrypting dbf files

Postby James Bott » Fri Sep 27, 2013 4:37 pm

Enrico,

Please have a look at Marco's message at the start of this thread.


Hmm, I guess you are telling me, no there are no record or field level decryption Six functions?

As I mentioned, it seems impractical to decrypt all DBFs when running a program. When it the program is multi-user, it gets a lot more complicated as the files need only to be decrypted when the first user runs the program. If the DBFs are large then it could take 10 minutes or more to decrypt the files. You would have to move all DBFs across the network twice--once to read and once to write.

Then when the last user exited the program all the files would then have to encrypted again and all the decrypted files would have to be securely erased. This would take even longer than opening the program.

While all the files are decrypted, they are vulnerable to unsecure access. Anyone could open the files and copy them.

Record or field level decryption seems to be the only feasible method of working with encrypted databases. So, I guess the Six driver is out and FW's own encrypt/decrypt functions are in. Since FW's functions only work with character fields, then we need to keep track of fieldtypes in a datadictionary file so we can convert the character data to the proper fieldtype on-the-fly.

Ah, the kingdom for SET ENCRYPTION ON.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encrypting dbf files

Postby Enrico Maria Giordano » Fri Sep 27, 2013 5:15 pm

James,

I think you have not read Marco's message carefully. Please do it. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: encrypting dbf files

Postby HunterEC » Sat Sep 28, 2013 8:49 am

James, Enrico:

The Sx_DBFencrypt & Sx_DBFdecrypt functions are used in a separate program, as the one I posted earlier in this post's thread. Afterwards you just open your DBF files and call the Sx_SetPass (cPassWord) function. The SIx driver handles everything transparently, meaning that you DON'T have to decrypt / encrypt any record at all before / after processing. It's done all automatically. As Antonio posted in one of my posts, all drivers (DBFCDX, DBFNTX) on Harbour supports these functions.

As to how to find out if a DBF is encrypted, you can use the Sx_TableType() and it will return a. 1 - for non encrypted b. 2 - encrypted. You can also encrypt the file a couple of times, just make sure you decrypt it in reverse order.

This function encrypts the whole record without the need to set all field types as character ones. It is not possible to encrypt just a couple of fields only. As James pointed out, it will be useless, better to encrypt all data fields.

Hope this clarifies a couple of questions.
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: encrypting dbf files

Postby Enrico Maria Giordano » Sat Sep 28, 2013 10:54 am

HunterEC,

I'm trying the following sample:

Code: Select all  Expand view  RUN
FUNCTION MAIN()

    USE MYTABLE EXCLUSIVE

    ? SX_DBFENCRYPT( "EMAG" )

    ? SX_TABLETYPE()

    INKEY( 0 )

    RETURN NIL


It prints: .F. and 1. What am I missing?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: encrypting dbf files

Postby reinaldocrespo » Sun Sep 29, 2013 2:43 am

Hi.

By simply changing to ADS rdd, you get to use their encryption functions on free .dbf tables as well as data dictionary bound tables -- and it is all very well documented on the help file.

Reinaldo.
User avatar
reinaldocrespo
 
Posts: 979
Joined: Thu Nov 17, 2005 5:49 pm
Location: Fort Lauderdale, FL

Re: encrypting dbf files

Postby HunterEC » Sun Sep 29, 2013 5:48 am

Enrico:

For encryption / decryption via the Sx_DBFencrypt() and Sx_DBFdecrypt() you have to open the DBF with the SIX driver. Afterwards you can keep using the DBFCDX or DBFNTX one. This is due to the fact that these function changes one byte at the DBF header that the Sx_TableType() inspects (first byte). That is the reason that I use a separate tool for encrypting / decrypting DBFs.
Code: Select all  Expand view  RUN
   FUNCTION MAIN()

        USE MYTABLE EXCLUSIVE VIA "SIX"   <--- AFTER THIS SX_TABLETYPE() WILL RETURN A 2

        ? SX_DBFENCRYPT( "EMAG" )

        ? SX_TABLETYPE()

        INKEY( 0 )

        RETURN NIL
HunterEC
 
Posts: 723
Joined: Tue Sep 04, 2007 8:45 am

Re: encrypting dbf files

Postby Enrico Maria Giordano » Sun Sep 29, 2013 7:13 am

HunterEC,

HunterEC wrote:For encryption / decryption via the Sx_DBFencrypt() and Sx_DBFdecrypt() you have to open the DBF with the SIX driver.


Sorry, no changes I'm still missing something... :-(

Code: Select all  Expand view  RUN
REQUEST SIXCDX


FUNCTION MAIN()

    USE POLIZZE EXCLUSIVE VIA "SIXCDX"

    ? SX_DBFENCRYPT( "EMAG" )

    ? SX_TABLETYPE()

    INKEY( 0 )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: encrypting dbf files

Postby Enrico Maria Giordano » Sun Sep 29, 2013 7:19 am

I also tried this but no lack:

Code: Select all  Expand view  RUN
#include "Hbsix.ch"


REQUEST SIXCDX


FUNCTION MAIN()

    USE POLIZZE EXCLUSIVE VIA "SIXCDX"

    ? SX_DBFENCRYPT( "EMAG" )

    ? SX_TABLETYPE()

    INKEY( 0 )

    RETURN NIL


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: encrypting dbf files

Postby James Bott » Sun Sep 29, 2013 3:36 pm

Hunter,

OK, I got SIX encryption working. Decrypting on the fly. I love it! This is going to be really useful.

Do you know what form of encryption is being used? I'm sure my customer's are going to want to know.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encrypting dbf files

Postby James Bott » Sun Sep 29, 2013 3:39 pm

Enrico,

It seems to be really transparent. You don't even need the REQUEST or the VIA.

Are you sure you are starting with an unencrypted file?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: encrypting dbf files

Postby Enrico Maria Giordano » Sun Sep 29, 2013 3:43 pm

James,

James Bott wrote:Are you sure you are starting with an unencrypted file?


Of course. :-(

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8725
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests