Encryption

From Axaptapedia

Jump to: navigation, search

This is a simple text encryption method for use in Axapta. It relies on the same integer key being used for both the encryption and decryption, and uses the TextBuffer class.

This is useful for storing external user details and passwords in Axapta. If a developer has access to the code, then they can easily see which encryption string is being used, but for casual use of the table browser or SQL Server tools it obscures the user details.

To encrypt a string, use the following code:

TextBuffer  textBuffer = new TextBuffer();
;
 
textBuffer.setText(_text);
textBuffer.encrypt(987654123); // Basic encryption 

To decrypt the string again, 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.

Although easy, this is not a particularly secure method of encryption. For this reason, it has been removed from version 4.0. The textBuffer.decrypt() method has been renamed textBuffer.decryptOld(), and is available for backward compatability. Some users, though, have reported errors in decryptOld(). See: TextBuffer encryption changes


For easy-to-use secure encryption there is an X++ implementation of the Rijndael algorithm from .Net posted here: X++ encryption class

Personal tools