The AL developer preview is still evolving with frequent updates. Follow us on the Dynamics NAV Team Blog for the announcements.


Takes a string as input and returns the encrypted value of the string.


String := ENCRYPT(Str)  


Value: Text or Code

The input string that will be encrypted.


The input string cannot exceed a length of 215 plain characters. If the input string includes special characters the length is even more reduced.

Property Value/Return Value

Value: Text or Code

The output string that is encrypted.


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.



The code example requires that you create the following text constant in the C/AL Globals window.

Text Text000

Text000 := ‘ABC123’;  
MESSAGE(‘Value: ‘ + Text000)  
Text000 := ENCRYPT(Text000);  
MESSAGE(‘Value: ‘ + Text000);  

This code example takes the string value ABC123 and outputs the encrypted value of the string. The encrypted value will vary from system to system due to differences in the encryption key.

See Also

AL Reference Guide