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

Home

 
4D v20 R7
New data key

New data key 


 

New data key ( passPhrase ) -> Function result 
Parameter Type   Description
passPhrase  Text in Passphrase to use to generate the AES data encryption key
Function result  Object in Object containing the key (encodedKey property)

The New data key command generates a binary data encryption key from the text passed in the passPhrase parameter.

The encoded key can be saved locally, in order to be stored on an removable device, like an USB key (see Storing data encryption keys in files in the 4D Design Reference). Connecting this device to the machine that hosts the encrypted database will automatically allow the user to access the encrypted data.

You can pass any character in passPhrase. The same passPhrase will always produce the same data encryption key.

 

Returned value

The returned object contains the following property:

PropertyTypeDescription
encodedKeyTextAES encryption key (SHA 256-bit) generated from the passPhrase

If an empty string was passed in passPhrase, the command returns null.

Example  

You want to save an encryption key in a .4DKeyChain file:

 C_OBJECT($dataKey)
 C_TEXT($passphrase)
 
 $passphrase:=Request("Enter the passphrase:")
 If(OK=1)
    $dataKey:=New data key($passphrase)
    TEXT TO DOCUMENT("generatedKey.4DKeyChain";JSON Stringify($dataKey))
 End if



See also 

4D Blog - New 4D commands to work with encrypted data
Decrypt data BLOB
Discover data key
Encrypt data BLOB
Encrypt data file
Register data key

 
PROPERTIES 

Product: 4D
Theme: Data Security
Number: 1611

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)