Command SET PASSWORD TO Professional
Sets the password used for data encryption/decryption.
SET PASSWORD TO [<cPassWord>]
To initiate encryption and decryption in the current workarea, this command should be executed.
After the password has been successfully set, all new records appended or updated will be encrypted as they are stored.
Please note that if a file has been encrypted without a prior usage of SET PASSWORD TO, it also needs to be decrypted without a call of this function. If no password has been set, eight ASCII 0's will be used for encryption and decryption.
To assure that the password is not easy accessible at runtime, it is stored in an encrypted form in memory.
1. Re-encrypt the table with the WRONG password. (Put it back to its former state.)
2. Set the CORRECT password.
3. Now decrypt the file with the CORRECT password.
#include "ads.ch"
// Install ADSDBE as default database engine.
PROCEDURE DbeSys
IF !DbeLoad( "ADSDBE" )
Alert( "ADSDBE could not be installed!" )
ENDIF
DbeSetDefault( "ADSDBE" )
RETURN
PROCEDURE Main
// Connect to database server.
LOCAL cConnect := "DBE=ADSDBE;SERVER=\\ALASKA\VOL1"
LOCAL oSession := DacSession():new( cConnect )
IF .NOT. oSession:isConnected()
Alert( "Connection to server could not be established!" )
QUIT
ENDIF
// Open TEST.DBF, set a password for this workarea and
// encrypt the table.
USE Test NEW EXCLUSIVE
SET PASSWORD TO Hobbit
IF AX_DBFEncrypt()
? "Encryption ok."
ELSE
? "Encryption FAILED!"
ENDIF
// Close databases and disconnect from server.
DbCloseAll()
oSession:disconnect()
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.