{"title":"System.ImportEncryptionKey(Text, Text) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-importencryptionkey-method/","by":"JOP-AL","license":"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.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-importencryptionkey-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Points to a password protected file that contains the key on the current server.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.ImportEncryptionKey(Text, Text) Method","slug":"systemimportencryptionkeytext-text-method","at":0,"chars":2690},{"level":2,"title":"Syntax","slug":"syntax","at":764,"chars":160},{"level":2,"title":"Parameters","slug":"parameters","at":924,"chars":185},{"level":2,"title":"Return Value","slug":"return-value","at":1109,"chars":238},{"level":2,"title":"Remarks","slug":"remarks","at":1347,"chars":190},{"level":2,"title":"Example","slug":"example","at":1537,"chars":1019},{"level":2,"title":"Related information","slug":"related-information","at":2556,"chars":134}],"text":"# System.ImportEncryptionKey(Text, Text) Method\n> Version: _Available or changed with runtime version 1.0._\nPoints 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.\n> NOTE\n> This method is supported only in Business Central on-premises.\n## Syntax\n```al\n[Ok := ]  System.ImportEncryptionKey(Path: Text, Password: Text)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nPath\nType: ../text/text-data-type\nSpecifies the file that contains the encryption key.\nPassword\nType: ../text/text-data-type\nSpecifies the password the protects the file.\n## Return Value\n*[Optional] Ok*\nType: ../boolean/boolean-data-type\ntrue 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.\n## Remarks\nIf 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.\n## Example\nThis code example uses the system-encryptionenabled-method and EncryptionExists<system-encryptionkeyexists-method> methods to do a check before importing the encryption key.\nThis example requires that you create a text constant ServerFileName.\n```al\nif EncryptionEnabled then\n        if EncryptionExists then\n          if not Confirm('Encryption has been enabled and the server already contains an encryption key.\\'\n          + 'Importing a key will overwrite any existing key and may result in lost data.\\\\'\n          + 'Do you wish to continue?') then\n            exit\n       else\n          if not Confirm('Importing a key different from the already configured key will result in data corruption.\\\\'\n          + 'Do you wish to continue?') then\n            exit\n\n      if not Upload('Upload encrypted key','','Encrypted Key File (*.ekey)|*.ekey','ExportedKey.ekey',ServerFileName) then\n        Exit;\n\n      ImportEncryptionKey(ServerFileName,'This is my personal secret');\n      Erase(ServerFileName);\n```\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}