Root > Reference > All Functions > DataProtect

Procedure DataProtect

Previous pageReturn to chapter overviewNext page   

Encrypts data.

 

Unit

EEncrypt

 

Syntax

 

Code (Delphi)

procedure DataProtect(

const AData: Pointer;

const ADataSize: Cardinal;

out AProtectedData: Pointer;

out AProtectedDataSize: Cardinal;

const ASameMachine: Boolean = False

); overload;

 

function DataProtect(

const AData: RawByteString;

const ASameMachine: Boolean = False

): RawByteString; overload;

 

procedure DataProtect(

var AData: TEncryptBuffer;

const ASameMachine: Boolean = False

); overload;

 

procedure DataProtect(

const AData: TEncryptBuffer;

out AProtectedData: TEncryptBuffer;

const ASameMachine: Boolean = False

); overload;

 

Parameters

AData [in]

Sensitive data to encrypt.

 

ADataSize [in]

Size of AData.

 

AProtectedData [out]

Encrypted data. Can be deleted by FreeMem function (but we recommend to use SecureFree function instead).

 

AProtectedDataSize [out]

Size of AProtectedData.

 

ASameMachine [in, optional]

False (default) - encrypt data using currently logged in user; True - encrypt data using computer info only.

 

AData [in]

Sensitive data to encrypt.

 

AData [in, out]

On input: sensitive data to encrypt. Must be allocated with AllocMem function.

On output: encrypted data (size will be different). Can be deleted by EncryptBufferFree or SecureFree functions.

 

AProtectedData [out]

Encrypted data (size will be different). Delete this data by EncryptBufferFree or SecureFree functions.

 

Return value

Encrypted data (size will be different).

 

Remarks

This function encrypts data. Typically, only a user with the same logon credential as the user who encrypted the data can decrypt the data (when ASameMachine is False). In addition, the encryption and decryption usually must be done on the same computer.

 

You can use this function to save data that you want to decrypt later. If you want to protect sensitive data in your process memory while running - use MemProtect function.

 

Call the DataUnprotect function to decrypt data encrypted with the DataProtect function. When you have finished using the sensitive information, clear it from memory by calling the FillChar function.

 

The function creates a session key to perform the encryption. The session key is derived again when the data is to be decrypted.

 

The function also adds a Message Authentication Code (MAC) (keyed integrity check) to the encrypted data to guard against data tampering.

 

See also




Send feedback... Build date: 2023-09-11
Last edited: 2023-09-11
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_eencrypt_dataprotect.php