|

Cryptography in AX using CryptoAPI class

    Hi Folks,

For some clients, you would require to encrypt some phrases or words like passwords. For this, we can use cryptography class(CryptoAPI) which would allow us to encrypt/decrypt the phrases. The following example explains about the CryptoAPI class.

    CryptoApi cryptoApi;
    Container cont,cont1;
    ContainerClass cc;
    ;
   /* Salt is like a password, While encrypting and descrypting the phrase, the CryptoAPI class has to instantiated with same salt(99999999999). The phrases/words are encrypted & decrypted based on the salt. */
    cryptoApi = new CryptoApi(99999999999);
    cc = new ContainerClass([“giridhar”]);
    cont = CryptoApi.encrypt(cc.toBlob()); // The encrypt method requires BLOB as a parameter
    cont1 = ContainerClass::blob2Container(CryptoApi.decrypt(cont));
    info(Strfmt(“Encrypted:%1”,BinData::dataToString(cont)));
    info(con2str(cont1));

Happy DAXing…………

Similar Posts

Leave a Reply to ashu Cancel reply

Your email address will not be published. Required fields are marked *

0 Comments

  1. Nice piece of code, additionally CryptoAPI class cannot be initialized on client. So in order to execute the code we need to make sure it runs on server. we can test this by creating a new static method in a class and use server keyword so that it always runs on server.

  2. Hi Giridhar –

    Please provide some information on the parameter used by CryptoAPI class, as of now it just says int64 type, not exactly getting how to map this to a salt key.

    Regards,
    Kori.