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

Home

 
4D v20.6
Decrypt data BLOB

Decrypt data BLOB 


 

Decrypt data BLOB ( blobToDecrypt ; keyObject | passPhrase ; salt ; decryptedBLOB ) -> Function result 
Parameter Type   Description
blobToDecrypt  BLOB in BLOB to decrypt
keyObject | passPhrase  Object, Text in JSON object containing the encryption key or passphrase for direct encryption key generation (text)
salt  Longint in Additional salt for algorithm
decryptedBLOB  BLOB in decrypted BLOB
Function result  Boolean in True if decryption has been correctly performed, False otherwise

The Decrypt data BLOB command decrypts the blobToDecrypt parameter with the same algorithm as 4D uses to decrypt data (AES-256) and returns the result in decryptedBLOB.

You can use either a keyObject or a passPhrase to decrypt the BLOB: 

  • keyObject: a JSON object containing the encryption key, with the same structure as the object returned by the New data key command 
  • passPhrase: a string used to generate the encryption key

The number passed in the salt parameter of Decrypt data BLOB must match the one used for encryption.

If the decryption is successful, the decrypted data is returned in the decryptedBLOB parameter and the command returns True.

In case of error, the BLOB is returned empty and the command returns false.

Example  

The following example shows how to decrypt an encrypted file located in the RESOURCES folder of the database:

 var $fileToDecrypt;$decryptedFile : 4D.File
 var $blobToDecrypt;$decryptedBlob : Blob
 var $result : Boolean
 
 $fileToDecrypt:=File("/RESOURCES/encryptedConfidential.txt")
 $decryptedFile:=File("/RESOURCES/decryptedConfidential.txt")
 
 $blobToDecrypt:=$fileToDecrypt.getContent()
 
 $result:=Decrypt data BLOB($blobToDecrypt;"myPassPhrase";MAXLONG;$decryptedBlob)
 $decryptedFile.setContent($decryptedBlob)

 

The passPhrase and salt used for decryption are identical to the passPhrase and salt used for encryption (see the Encrypt data BLOB example).



See also 

Encrypt data BLOB
Encrypt data file
Encrypt your own data with the 4D algorithm
New data key

 
PROPERTIES 

Product: 4D
Theme: Data Security
Number: 1774

This command can be run in preemptive processes

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v19

 
ARTICLE USAGE

4D Language Reference ( 4D v20)
4D Language Reference ( 4D v20.1)
4D Language Reference ( 4D v20.2)
4D Language Reference ( 4D v20.3)
4D Language Reference ( 4D v20.4)
4D Language Reference ( 4D v20.5)
4D Language Reference ( 4D v20.6)