encrypting dbf files

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

Re: encrypting dbf files

Post by James Bott »

Enrico,
As far as I know, SIXCDX is included in xHarbour's DBFCDX.
That was the conclusion that I came to. Probably Hunter has not tried it recently and thus his statement that you have to use the Six driver to encrypt.

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

Re: encrypting dbf files

Post by Enrico Maria Giordano »

James,
James Bott wrote:Enrico,
As far as I know, SIXCDX is included in xHarbour's DBFCDX.
That was the conclusion that I came to. Probably Hunter has not tried it recently and thus his statement that you have to use the Six driver to encrypt.

James
I agree. Anyway, I would like to know how to get it to work with memo fields too...

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

Re: encrypting dbf files

Post by James Bott »

Enrico,

I am unable to encrypt memo files too.

Hunter,

Are you perhaps using the original SIX library instead of the xHarbour one?

Maybe memo field encryption has not yet been implemented in the xHarbour version.

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

Re: encrypting dbf files

Post by James Bott »

Six Driver NG Guide online

http://www.ousob.com/ng/six3/index.php

From the section on SX_encrypt() (Note that this encrypts a string and is not the same as SX_dbfencrypt() but we can probably assume that this uses the same encryption method).
http://www.ousob.com/ng/six3/ng25e56.php
------------
Description: Sx_Encrypt() and it related function Sx_Decrypt() provide
an easy way to integrate data security to a system. The
encryption engine provides security through the use of a
64-bit (8 byte) security code and multi-adaptive computa-
tion. Multi-adaptive computation ensures a wide uniqueness
within the outputted encrypted string. If a string of all
blanks were encrypted you would see a wide distribution of
characters. This ensures a reasonable amount of security
at a small speed penalty.

Of course, the best way to protect your data is to keep it
away from those who shouldn't have access to it. Protect
your passwords, and don't store them in .DBF files.

This encryption/decryption method is _not_ DES (Data
Encryption Standard) compliant, so it can be used in
programs distributed both in the US and Overseas.
OK, 64bit encryption is not very good, but it will prevent casual users from getting into the DBFs. It would be nice to have the option of higher level encryption but there would also be a speed penalty.

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

Re: encrypting dbf files

Post by James Bott »

More on encrypted memo fields:

This SIX driver apparently doesn't work with memo files. However, I think we can come up with a workaround. You will need to do something like the following.

1) Create a DBF without a memo field (this can be encrypted using SX_DBFENCRYPT(). There needs to be a primary-key field containing a unique non-blank value. Use the primary key field to link to another DBF containing only a memo field.

2) Create a subclass of TDatabase (or TData) and write new save() and load() methods. In these methods you need to automatically lookup the memo field associated with the original primary-key. Then encrypt or decypt the memo field data as needed.

The above will make everything transparent and automatic.

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

Re: encrypting dbf files

Post by James Bott »

Regarding my previous message, you will also need to add new Append() and Delete() methods. These will need to add and delete records from both files.

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

Re: encrypting dbf files

Post by HunterEC »

James, Enrico:

I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted).
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: encrypting dbf files

Post by Enrico Maria Giordano »

Hunter,
HunterEC wrote:James, Enrico:

I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted).
Sorry, I didn't get it working... :-(

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

Re: encrypting dbf files

Post by HunterEC »

Enrico:

If you can email me (morenoec2007 at hotmail dot com) your program or a sample program and your DBFs, I'll give it a try. Thank you.
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: encrypting dbf files

Post by Enrico Maria Giordano »

Hunter,
HunterEC wrote:Enrico:

If you can email me (morenoec2007 at hotmail dot com) your program or a sample program and your DBFs, I'll give it a try. Thank you.
Here it is:

Code: Select all

FUNCTION MAIN()

    DBCREATE( "MYTEST", { { "TEST1", "C", 35, 0 },;
                          { "TEST2", "M", 10, 0 } } )

    USE MYTEST EXCLUSIVE

    APPEND BLANK

    REPLACE FIELD -> test1 WITH "Test1"
    REPLACE FIELD -> test2 WITH "Test2"

    CLOSE

    USE MYTEST EXCLUSIVE

    ? SX_DBFENCRYPT( "EMAG" )

    ? SX_ENCRYPT( "EMAG" )

    ? SX_TABLETYPE()

    CLOSE

    INKEY( 0 )

    RETURN NIL
EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: encrypting dbf files

Post by James Bott »

Hunter,
I do encrypt my DBFs with a 16 bit Clipper utility program using the SIX driver. Memos do encrypt. In 32 bit you can encrypt the memo field before storing it with the Sx_encrypt (cPassword) function and that's it (in case that the memo fields does not get encrypted).
I am not sure I understand what you are saying. Are you confirming that 32bit FWH programs cannot encrypt DBF files containing a memo field?

Yes, you can encrypt a memo field using SX_encrypt() however you cannot cannot create the typical DBF with a memo field as the entire DBF cannot be encrypted. So as I mentioned in previous messages, you have to create the main DBF WITHOUT a memo field and another DBF containing only the memo field and do the linking via code and encrypting/decrypting using Sx_encrypt() and Sx_decrypt() which considerably complicates things.

Do you know why memo field encryption was never implemented in 32bits?

Regards,
James
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: encrypting dbf files

Post by Enrico Maria Giordano »

James,
James Bott wrote:Do you know why memo field encryption was never implemented in 32bits?
It was a Przemek decision. :-(

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

Re: encrypting dbf files

Post by James Bott »

Enrico,
It was a Przemek decision.
I wonder why. It seems that it would be simple to implement since the encryption/decryption code is already working. Maybe there is some other technical issue...

Maybe some user requests would get him motivated.

James
User avatar
Rick Lipkin
Posts: 2397
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: encrypting dbf files

Post by Rick Lipkin »

To All

There functions have served me well over the years .. I copied this ( public domain ) code from an old Clipper Tools book some time ago and have modified it from time to time.

As you can see .. I added msginfo() to test the values and rem'd them out. Feel free to try them for yourselves. Please note that this code offsets the data by one character at the beginning and you may need to adjust the width of your variables.

Rick Lipkin

Code: Select all

//------------------------
Func ENCRYPT( TO_DO )

Local PadBack,Done,Qaz

PadBack := Len(To_Do)
*msginfo( "Padback" )
*msginfo( PadBack )
Done    := " "

TO_DO := ALLTRIM(TO_DO)

FOR QAZ := LEN(TO_DO) to 1 STEP -1
    DONE := DONE + CHR(ASC(SUBSTR(TO_DO, QAZ, 1)) + 104)
NEXT

*MsgInfo( "In Encrypt" )
*MsgInfo( Done )
*msginfo( Len( Done ))

RETURN( Fill_Out( Done, PadBack ))

//--------------------
Func DENCRYPT( TO_DO )

LOCAL PADBACK := LEN(TO_DO), DONE := " ", QAZ
TO_DO := ALLTRIM(TO_DO)

FOR QAZ := LEN(TO_DO) to 1 STEP -1
    DONE := DONE + CHR(ASC(SUBSTR(TO_DO, QAZ, 1)) - 104)
NEXT

RETURN( FILL_OUT(DONE, PADBACK))

//----------------------
Func FILL_OUT( Done, PadBack )

*   MsgInfo( "In Fill_Out Pcount")
*   msginfo( pcount())

*   Msginfo( len( done ))

IF PCOUNT() = 1
   PadBack := 80
ELSE

*   msginfo( "Initial PadBack" )
*   msginfo(  PadBack )

   IF TYPE("PadBack") = "C"
      PadBack := VAL(PadBack)
   ENDIF

   *   PadBack := IIF(PadBack <= 1, 80, PadBack)
   If PadBack >= 1
   Else
      PadBack := 80
   Endif

  * PadBack := IIF(PadBack < 1, 80, PadBack)
*   msginfo( "End PadBack")
*   msginfo( PadBack )

ENDIF

*msginfo( "if PadBack <= len(Done)")
*msginfo( PadBack)
*msginfo( len(Done))

IF PadBack <= LEN(Done)
*   Msginfo( "Return Done")
*   Msginfo( Done )
*   msginfo( len(done ))
   RETURN(Done)
ENDIF

RETURN(Done + SPACE(PadBack - LEN(Done)))


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

Re: encrypting dbf files

Post by Enrico Maria Giordano »

Rick,
Rick Lipkin wrote:To All

There functions have served me well over the years .. I copied this ( public domain ) code from an old Clipper Tools book some time ago and have modified it from time to time.
Thank you. We are discussing an encrypting system at RDD level here. It already exists but unfortunately it doesn't work with memo fields.

EMG
Post Reply