AES Encryption and Decryption Using the N/crypto

/**  * @NApiVersion 2.x  * @NScriptType Suitelet  */ define([‘N/crypto’, ‘N/encode’, ‘N/log’], function (crypto, encode, log) {   function onRequest(context) {     let secretKey = crypto.createSecretKey({       guid: ‘f3e6c67a-1a47-4fd2-8b09-cdbcf36a3ef7’,       encoding: encode.Encoding.UTF_8     });     let textToEncrypt = ‘SensitiveData123’;     // Encrypt Data     let encrypted = crypto.encrypt({       algorithm: crypto.EncryptionAlg.AES,       key: secretKey,       input: textToEncrypt,       inputEncoding: encode.Encoding.UTF_8,       outputEncoding: encode.Encoding.BASE_64     });     log.debug(‘Encrypted:’, encrypted);     // Decrypt Data… Continue reading AES Encryption and Decryption Using the N/crypto

Encoding and Decoding Base64 with the N/crypto Module

/**  * @NApiVersion 2.x  * @NScriptType Suitelet  */ define([‘N/crypto’, ‘N/log’], function (crypto, log) {   function onRequest(context) {     let text = ‘Sample Data’;           // Encode to Base64     let encoded = crypto.encode({       input: text,       outputEncoding: crypto.Encoding.BASE_64     });     log.debug(‘Encoded (Base64):’, encoded);     // Decode from Base64     let decoded = crypto.decode({       input: encoded,       inputEncoding: crypto.Encoding.BASE_64     });     log.debug(‘Decoded:’, decoded);     context.response.write(‘Encoded:… Continue reading Encoding and Decoding Base64 with the N/crypto Module

How to Hash Data in NetSuite Using the N/crypto Module

/**  * @NApiVersion 2.x  * @NScriptType Suitelet  */ define([‘N/crypto’, ‘N/log’], function (crypto, log) {   function onRequest(context) {     let textToHash = ‘Sample Text’;           let hash = crypto.hash({       algorithm: crypto.HashAlg.SHA256,       input: textToHash     });     log.debug(‘Hashed Value:’, hash);     context.response.write(‘SHA-256 Hashed Value: ‘ + hash);   }   return {     onRequest: onRequest   }; }); How It Works The crypto.hash() function takes… Continue reading How to Hash Data in NetSuite Using the N/crypto Module