Command SET PASSWORD TO Professional

Sets the password used for data encryption/decryption.

Syntax
SET PASSWORD TO [<cPassWord>]
Parameters
<cPassword>
In <cPassword> the character string is stored which represents the chosen password. Please note that the string may only be up to eight characters long and that it will be handled case-sensitive. That means that "HOBBIT" will be interpreted as a different password than "Hobbit".
Using the command without cPassWord will clear the password.
Description

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.

If you accidentally decrypted a file with a wrong password, you have to do the following to decrypt it properly:

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.

Examples
#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 
Feedback

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.