Encryption and decryption in AX

When handling some high security data like password etc. its always better to use the encryption – decryption methodology. This small example shows this methodology in AX. It uses TextBuffer class of AX

 
To encrypt a string, use the following code:
TextBuffer  textBuffer = new TextBuffer();
;
 
textBuffer.setText(_text);
textBuffer.encrypt(987654123); // Basic encryption
To decrypt a string, use the following code:
TextBuffer  textBuffer = new TextBuffer();
;
 
textBuffer.setText(_text);
textBuffer.decrypt(987654123);
decryptedString = textBuffer.getText();
In these examples, the encryption key is 987654123. This can be any integer.

One thought on “Encryption and decryption in AX

  1. This works in Axapta 3.0 and below, but not in AX 4.0, as it is considered "insecure".There\’s a testBuffer.decryptOld() to retrieve your old values :-)Use the CryptoAPI kernel class instead.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s