Share via


EXPORTENCRYPTIONKEY

Returns a password protected temporary filepath containing the encryption key.

When encrypting or decrypting data in Dynamics NAV, an encryption key is used. Dynamics NAV uses a single key per tenant and every tenant will have a different key. Keys can be exported to a file which may be necessary in the case of upgrading or migrating a system from one set of hardware to another. The EXPORTENCRYPTIONKEY function allows an administrator to specify a destination file for the key and specify a password protection for the file.

Important

Use the System Restore permission set in Dynamics NAV to allow importing the encryption key.

Syntax

TempFile EXPORTENCRYPTIONKEY(pwd)  

Parameters

pwd
Value: String

Specifies the password for the encryption key file.

Property Value/Return Value

Value: Text

A temporary filepath to where the key is exported.

Exceptions

If encryption is not enabled or the encryption key is not found, the following error will be displayed: An encryption key is required to complete the request.

Example

This code example uses the EXPORTENCRYPTIONKEY function to return a password protected file that contains an encryption key. With the DOWNLOAD function the file is sent from the Microsoft Dynamics NAV Server computer to the client computer.

This example requires that you create the following text constants: ExportFileName and ClientFileName.

IF NOT ENCRYPTIONENABLED THEN  
        ERROR('Encryption has not been enabled.');  
      ExportFileName := EXPORTENCRYPTIONKEY('This is my personal secret');  

      ClientFileName := 'ExportedKey.ekey';  
      DOWNLOAD(ExportFileName,'Save the encrypted key file','','Encrypted Key File (*.ekey)|*.ekey',ClientFileName);  

      ERASE(ExportFileName);  

See Also

System
Technical Reference
C/SIDE Reference Guide
Encryption Key Management