This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Discover data key

Discover data key 


 

Discover data key -> Function result 
Parameter Type   Description
Function result  Boolean in True if a valid encryption key for the currently open data file has been found, else False

The Discover data key command searches for a valid encryption key corresponding to the currently opened data file at the root level of all connected devices and returns True if successful. 

Connected devices to be searched include USB keys or external disks. A valid encryption key is necessary to allow read/write access to an encrypted database. This command can be called, for example, at database startup, after the user has been invited to connect a USB key.

Key files (".4DKeyChain" extension files) must be stored at the top level of connected devices (the search will not go through the folder hierarchy). Encryption keys must be saved in JSON format (see Storing data encryption keys in files in the 4D Design Reference).

 

Returned value

  • True if a valid encryption key is found for the current opened data file, in which case:
    • the encryption key is applied if necessary so that encrypted data is usable (access to read / write operations).
    • the encryption key is added to the 4D keychain.
  • False if no valid encryption key is found for the current opened data file, thus access to the data is not possible. 

Example  

 C_OBJECT($status)
 C_BOOLEAN($keyFound)
 
 $status:=ds.encryptionStatus()
 
 If(($status.isEncrypted)&(Not($status.keyProvided))) //no key is available
  // thus access to encrypted data is not allowed
    $keyFound:=Discover data key
    If($keyFound=True)
       ALERT("A valid encryption key has been found.")
    End if
 End if



See also 

4D Blog - New 4D commands to work with encrypted data
New data key

 
PROPERTIES 

Product: 4D
Theme: Data Security
Number: 1639

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)