Is there a fivewin function that encrypts dbf files by closing or interupting the fivewin program so that they can not be modified with an external program
Is there a fivewin function that encrypts dbf files by closing or interupting the fivewin program so that they can not be modified with an external program
You can use FWH functions Encrypt() and Decrypt() so all info inside the DBF is encrypted.
field->myfield := Encrypt( "value", cPassword )
Note that when using Encrypt/Decrypt all fields must be character format.
#include "fivewin.ch"
#include "Dbinfo.ch"
FUNCTION MAIN
SELECT 0
USE t090
DBINFO( DBI_PASSWORD, "12345678" )
browse()
RETURN NIL#include "DbStruct.ch"
#include "Dbinfo.ch"
FUNCTION MAIN( cFileIn, cFileOut, cCodice )
LOCAL aStruct := {}
// open file to read to obtain structure
USE &(cFileIn) ALIAS filein
aStruct := DBSTRUCT()
USE
// create encrypted file
DBCREATE( cFileOut, aStruct )
USE &(cFileOut) ALIAS fileout
DBINFO( DBI_PASSWORD, cCodice ) // cCodice = "12345678" in example
APPEND FROM &(cFileIn)
RETURN NILWhat includes are necessary to use encrypt() and decrypt() files please
Jds:
(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.
3. Sx_SetPass (cPassword) - set / changes password to be used in the encryption functions.
With the above mentioned suggestions the database fields remains as you designed them (Date, Numerics, Memos, etc.).
The drawback with the Encrypt() and Decrypt() functions is that, as James pointed out correctly, all fields must be character.
Hope this helps.
So, if I understood it well, the user has to use a password to encrypt;
So it is not possible that by exiting the program all dbf files can be encrypted so that the user can not modify the dbf files with an external program
So, if I understood it well, the user has to use a password to encrypt;
So it is not possible that by exiting the program all dbf files can be encrypted so that the user can not modify the dbf files with an external program
Jds:
Steps on using encryption:
1. You encrypt all tables with a tool that uses the Sx_DBFencrypt (cPassword) function.
2. Your program has the password either hard coded or in an external dbf.
3. Make SURE if you hard coded it to not set it up as a literal, build it as a result of some sort of mathematical function.
4. This way it cannot be retrieved via a binary editor since the compiler cannot "resolve" or pre-process it at compile time.
5. This way DBF are ALWAYS ENCRYPTED.
Hope this helps. I've been using encryption since the old Clipper 5.2e/DOS days (SIx driver).
1. You encrypt all tables with a tool that uses the Sx_DBFencrypt (cPassword) function.
#include "Common.ch"
#include "FiveWin.ch"
PROCEDURE Main (cFileName, cPassWord)
DEFAULT cFileName TO ""
DEFAULT cPassword TO ""
IF ! EMPTY(cPassword)
IF FILE(cFileName)
USE (cFileName) VIA "DBFCDX" EXCLUSIVE
Sx_DBFencrypt (cPassword)
USE
MsgInfo("File: " + cFileName + " Encrypted")
ELSE
MsgInfo("File: " + cFileName + " NOT Found")
ELSE
MsgInfo ("Empty Passwords Not Allowed")
ENDIF
RETURNIs it possible to encrypt only some fields of a table .
For example, in a People dbf file, i only want to Encrypt Name and Adress .
Thanks
i only want to Encrypt Name and Adress
Hunter,
Thanks for the example code.
Do you have any ideas on how we could check to see if a file is already encrypted? I just thought it might be handy to prevent ever encrypting a file twice.
James
I use the free ADS encryption. It encrypts the entire file.