Comprehensive guide to secure customer data through robust encryption solutions. Learn about methods to minimize risks of unauthorized access and data breaches while complying with the latest security standards.
For development purposes, provide the Encryption and Decryption Tool.
You may download it via this link and verify the results are accurate.cf> In macOS, it requires allowing launching this app in the “Privacy & Security” settings menu.
Select Encryption Module AES-256/GCM-256 and API Key or secretKey
Once issued, secretKey will not be displayed again. If lost, please reissue and use it.
3
Perform AES-256/GCM-256 Encryption Using the Provided API Key
Before performing AES-256 encryption, please verify the query string encryption and decryption steps.
If you have received a secretKey, please use the secretKey.
4
Add Encrypted Data to the URL as the 'encrypted' Query Parameter
Caution: The following query parameters are not encrypted: pid, lang, sid, action.
The pid, lang query strings and the sid, action query strings used on the “Additional Process (Injection)” page do not support encryption.
var crypto = require('crypto');var hashedKey = crypto.createHash('sha256').update(APIKEY).digest();
2
Encryption Example
Below are examples of encrypting data using AES-256
Copy
Ask AI
var crypto = require('crypto'); /** * @param {string} data - Stringified JSON data * @param {string} apiKey - Project API key * @returns {string} Encrypted data * * for exact encryption, use formatJSON. * example below, * const data = { userid: "10912301", email: "email@email.com" * }; * * do not use string direct way, like * `{"userid":"10912301","email":"email@email.com"}` * which is not same as expected encryption. */ function encrypt(data, apiKey) { var hashedKey = crypto.createHash('sha256').update(apiKey).digest(); var cipher = crypto.createCipheriv('aes-256-ecb', hashedKey, null); return cipher.update(data, 'utf8', 'base64') + cipher.final('base64'); }
3
GCM Encryption Example
Below are examples of encrypting data using AES-256-GCM
Copy
Ask AI
var crypto = require('crypto');/** * @param {string} data - Stringified JSON data * @param {string} apiKey - Project API key * @returns {string} Encrypted data in hex format (IV + ciphertext + tag) * * GCM mode provides authenticated encryption and includes IV and authentication tag. * Return value is hex string encoded form of 12-byte IV + ciphertext + 16-byte authentication tag. */function encryptGCM(data, apiKey) { var hashedKey = crypto.createHash('sha256').update(apiKey).digest(); var iv = crypto.randomBytes(12); var cipher = crypto.createCipheriv('aes-256-gcm', hashedKey, iv); var encrypted = cipher.update(data, 'utf8'); encrypted = Buffer.concat([encrypted, cipher.final()]); var tag = cipher.getAuthTag(); var result = Buffer.concat([iv, encrypted, tag]); return result.toString('hex');}/** * @param {string} encryptedHex - Hex encoded encrypted data * @param {string} apiKey - Project API key * @returns {string} Decrypted data */function decryptGCM(encryptedHex, apiKey) { var hashedKey = crypto.createHash('sha256').update(apiKey).digest(); var encryptedBuffer = Buffer.from(encryptedHex, 'hex'); var iv = encryptedBuffer.slice(0, 12); var tag = encryptedBuffer.slice(-16); var encrypted = encryptedBuffer.slice(12, -16); var decipher = crypto.createDecipheriv('aes-256-gcm', hashedKey, iv); decipher.setAuthTag(tag); var decrypted = decipher.update(encrypted); decrypted = Buffer.concat([decrypted, decipher.final()]); return decrypted.toString('utf8');}
4
Decryption Example
Below are examples of decrypting data encrypted with AES-256
Copy
Ask AI
var crypto = require('crypto'); /** * @param {string} encryptedData * @param {string} apiKey * @returns {string} Decrypted data */ function decrypt(encryptedData, apiKey) { var hashedKey = crypto.createHash('sha256').update(apiKey).digest(); var decipher = crypto.createDecipheriv('aes-256-ecb', hashedKey, null); return decipher.update(encryptedData, 'base64', 'utf8') + decipher.final('utf8'); }
5
GCM Decryption Example
Below are examples of decrypting data encrypted with AES-256-GCM
Copy
Ask AI
var crypto = require('crypto');/** * @param {string} encryptedHex - Hex encoded encrypted data (IV + ciphertext + tag) * @param {string} apiKey - Project API key * @returns {string} Decrypted data */function decryptGCM(encryptedHex, apiKey) { var hashedKey = crypto.createHash('sha256').update(apiKey).digest(); var encryptedBuffer = Buffer.from(encryptedHex, 'hex'); // Separate IV, ciphertext, and tag var iv = encryptedBuffer.slice(0, 12); var tag = encryptedBuffer.slice(-16); var encrypted = encryptedBuffer.slice(12, -16); var decipher = crypto.createDecipheriv('aes-256-gcm', hashedKey, iv); decipher.setAuthTag(tag); var decrypted = decipher.update(encrypted); decrypted = Buffer.concat([decrypted, decipher.final()]); return decrypted.toString('utf8');}
Encrypt data for secure transmission in API methods (GET, POST, PATCH) and WEBHOOKs. API methods use the AES-256-ECB encryption method, while WEBHOOKs use AES-256-CBC encryption. Ensure that secure data transfer is enabled before using it to protect sensitive information.If this option is enabled, the request body must be encrypted. Inquire about a body parameter that is encrypted data. It is necessary to encrypt AES-256-ECB and refer to the Key Features and instructions on how to encrypt.