# System.ImportEncryptionKey(Text, Text) Method
> Version: _Available or changed with runtime version 1.0._
Points to a password protected file that contains the key on the current server. When encrypting or decrypting data in Dynamics 365 Business Central, an encryption key is used. A single key is used per tenant, and every tenant will have a different key. Keys can be created or imported if one exists already, as may be the case if upgrading or migrating a system from one set of hardware to another. The IMPORTENCRYPTIONKEY method allows an administrator to specify a file (password protected) which contains a key and imports it to the current Dynamics 365 Business Central service.
> NOTE
> This method is supported only in Business Central on-premises.
## Syntax
```al
[Ok := ]  System.ImportEncryptionKey(Path: Text, Password: Text)
```
> NOTE
> This method can be invoked without specifying the data type name.
## Parameters
Path
Type: ../text/text-data-type
Specifies the file that contains the encryption key.
Password
Type: ../text/text-data-type
Specifies the password the protects the file.
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
If the import key file cannot be imported, the following error will be displayed: Import Failed. The provided encryption key file contains invalid data and could not be imported.
## Example
This code example uses the system-encryptionenabled-method and EncryptionExists<system-encryptionkeyexists-method> methods to do a check before importing the encryption key.
This example requires that you create a text constant ServerFileName.
```al
if EncryptionEnabled then
        if EncryptionExists then
          if not Confirm('Encryption has been enabled and the server already contains an encryption key.\'
          + 'Importing a key will overwrite any existing key and may result in lost data.\\'
          + 'Do you wish to continue?') then
            exit
       else
          if not Confirm('Importing a key different from the already configured key will result in data corruption.\\'
          + 'Do you wish to continue?') then
            exit

      if not Upload('Upload encrypted key','','Encrypted Key File (*.ekey)|*.ekey','ExportedKey.ekey',ServerFileName) then
        Exit;

      ImportEncryptionKey(ServerFileName,'This is my personal secret');
      Erase(ServerFileName);
```
## Related information
system-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-importencryptionkey-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-importencryptionkey-method/
