Skip to main content
Version: 21 R3

Register data key

Register data key ( curPassPhrase : Text ) : Boolean
Register data key ( curDataKey : Object ) : Boolean

ParameterTypeDescription
curPassPhraseText→Current passphrase
curDataKeyObject→Current data encryption key
Function resultBoolean←True if the encryption key has been successfully added to the 4D keychain, False if it was already in the 4D keychain
History
ReleaseChanges
17 R5Created

Description​

The Register data key command adds the data encryption key passed in parameter to the 4D keychain.

The 4D keychain is a set of one or more data encryption key(s) loaded in memory which 4D automatically scans when a data key is required to decrypt/encrypt a data file. For more information, please refer to Encrypting data.

In the first parameter, pass the curPassPhrase or curDataKey that defines the encryption key to add:

  • curPassPhrase: String used to generate the encryption key. When you use this parameter, an encryption key is generated.
  • curDataKey: Object (with encodedKey property) that contains the data encryption key. This key may have been generated with the New data key command.

Returned value

  • True if the encryption key is successfully loaded in the 4D keychain.
  • False if the same encryption key was already present in the 4D keychain.

Example​

 var $passphrase : Text
 var $added : Boolean
 
 $passphrase:=Request("Enter the passphrase:")
 If(OK=1)
    $added:=Register data key($passphrase)
 
    OPEN DATA FILE("data.4DD") //No key required, it is in the 4D keychain
 End if

See also​

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

Properties​

Command number1638
Thread safeyes