dbase III/IV file encrypted

Moderator: Enrico Maria Giordano

dbase III/IV file encrypted

Postby lorenzoazz » Fri Jan 28, 2022 7:19 pm

I am asking if it is possible to encrypt an entire .dbf file (without memo) by setting the flag in the dbf header?
And then?
What do i have to do to read and write the fields in the .dbf ?


Thanks
Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: dbase III/IV file encrypted

Postby Enrico Maria Giordano » Fri Jan 28, 2022 10:20 pm

lorenzoazz wrote:I am asking if it is possible to encrypt an entire .dbf file (without memo) by setting the flag in the dbf header?


Add this just after the USE YOURDBF command:

Code: Select all  Expand view  RUN
DBINFO( DBI_PASSWORD, cPsw )


lorenzoazz wrote:And then?
What do i have to do to read and write the fields in the .dbf ?


Nothing special. You read and write as usual. The only limitation, as you already noted, is that you can't encrypt a DBF with memo fields.

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

Re: dbase III/IV file encrypted

Postby lorenzoazz » Sat Jan 29, 2022 9:32 am

Ok, but i just want to use the dbf with an old VB6 program that uses a JET connection like this

"Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBase IV;Data Source="

I suppose that i must change the encrypted flag in dbf file header in some way (do not know how), and then open with a password that i set in my vb6 script when opening .

Thanks ( Grazie)
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am


Re: dbase III/IV file encrypted

Postby lorenzoazz » Sat Jan 29, 2022 9:51 am

I tried the suggestion but i cannot find DBI_PASSWORD definition.

Anyway my intent is to make the dbf unreadable by normal dbf tools, to protect privacy outside from the specific software that created and use the dbf.

Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: dbase III/IV file encrypted

Postby Enrico Maria Giordano » Sat Jan 29, 2022 9:58 am

lorenzoazz wrote:I tried the suggestion but i cannot find DBI_PASSWORD definition.


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


lorenzoazz wrote:Anyway my intent is to make the dbf unreadable by normal dbf tools, to protect privacy outside from the specific software that created and use the dbf.


That's exactly what you achieve using DBI_PASSWORD.

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

Re: dbase III/IV file encrypted

Postby lorenzoazz » Sat Jan 29, 2022 1:17 pm

Cannot find definition for DBI_PASSWORD
here are all DBI_ the constant i found for dbinfo()


/* constants for dbInfo() */
#define DBI_ISDBF 1 /* Does this RDD support DBFs? */
#define DBI_CANPUTREC 2 /* Can this RDD Put Records? */
#define DBI_GETHEADERSIZE 3 /* Data file's header size */
#define DBI_LASTUPDATE 4 /* The last date this file was written to */
#define DBI_GETDELIMITER 5 /* The delimiter (as a string) */
#define DBI_SETDELIMITER 6 /* The delimiter (as a string) */
#define DBI_GETRECSIZE 7 /* The size of 1 record in the file */
#define DBI_GETLOCKARRAY 8 /* An array of locked records' numbers */
#define DBI_TABLEEXT 9 /* The data file's file extension */
#define DBI_FULLPATH 10 /* The Full path to the data file */

#define DBI_ISFLOCK 20 /* Is there a file lock active? */
#define DBI_CHILDCOUNT 22 /* Number of child relations set */
#define DBI_FILEHANDLE 23 /* The data file's OS file handle */
#define DBI_BOF 26 /* Same as bof() */
#define DBI_EOF 27 /* Same as eof() */
#define DBI_DBFILTER 28 /* Current Filter setting */
#define DBI_FOUND 29 /* Same as found() */
#define DBI_FCOUNT 30 /* How many fields in a record? */
#define DBI_LOCKCOUNT 31 /* Number of record locks */
#define DBI_VALIDBUFFER 32 /* Is the record buffer valid? */
#define DBI_ALIAS 33 /* Name (alias) for this workarea */
#define DBI_GETSCOPE 34 /* The codeblock used in LOCATE */
#define DBI_LOCKOFFSET 35 /* The offset used for logical locking */
#define DBI_SHARED 36 /* Was the file opened shared? */
#define DBI_MEMOEXT 37 /* The memo file's file extension */
#define DBI_MEMOHANDLE 38 /* File handle of the memo file */
#define DBI_MEMOBLOCKSIZE 39 /* Memo File's block size */

#define DBI_DB_VERSION 101 /* Version of the Host driver */
#define DBI_RDD_VERSION 102 /* current RDD's version */

/* HARBOUR extension */
#define DBI_LOCKSCHEME 128 /* Locking scheme used by RDD */
#define DBI_ISREADONLY 129 /* Was the file opened readonly? */
#define DBI_ROLLBACK 130 /* Rollback changes made to current record */

#define DBI_USER 1000 /* User-defined DBI_ constants */

/* BLOB support - definitions for internal use by BLOB.CH */
#define DBI_BLOB_DIRECT_EXPORT 201
#define DBI_BLOB_DIRECT_GET 202
#define DBI_BLOB_DIRECT_IMPORT 203
#define DBI_BLOB_DIRECT_PUT 204
#define DBI_BLOB_ROOT_GET 205
#define DBI_BLOB_ROOT_PUT 206
#define DBI_BLOB_ROOT_LOCK 207
#define DBI_BLOB_ROOT_UNLOCK 208

/* CA-CLIPPER documented for public use */
#define DBI_BLOB_DIRECT_LEN 209
#define DBI_BLOB_DIRECT_TYPE 210
#define DBI_BLOB_INTEGRITY 211
#define DBI_BLOB_OFFSET 212
#define DBI_BLOB_RECOVER 213

#define DBS_BLOB_GET 201 /* This is internal definition */
#define DBS_BLOB_LEN 202
#define DBS_BLOB_OFFSET 203
#define DBS_BLOB_POINTER 204
#define DBS_BLOB_TYPE 205

#define BLOB_EXPORT_APPEND 1
#define BLOB_EXPORT_OVERWRITE 0
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am

Re: dbase III/IV file encrypted

Postby Enrico Maria Giordano » Sat Jan 29, 2022 1:50 pm

Inside dbinfo.ch:

Code: Select all  Expand view  RUN
#define DBI_PASSWORD            131  /* Workarea password */


Please update your Harbour or xHarbour compiler.

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

Re: dbase III/IV file encrypted

Postby lorenzoazz » Sat Jan 29, 2022 6:04 pm

Thanks Enrico

Lorenzo
lorenzoazz
 
Posts: 37
Joined: Mon Jun 29, 2015 7:41 am


Return to All products support

Who is online

Users browsing this forum: No registered users and 3 guests