Payout Encryption Guide
Payout Encryption Guide
To enhance security, all payout requests must be encrypted using AES-256-CBC before sending to the API.
Step 1: Get Your Encryption Key
Retrieve your encryption key from the PayHub Dashboard.
Step 2: Encrypt the Request Data
Below is a Node.js example using crypto-js:
const CryptoJS = require('crypto-js');
const ENCRYPTION_KEY = 'your-encryption-key';
const IV_LENGTH = 16;
// Derive 32-byte key
function deriveKey(secret) {
return CryptoJS.SHA256(secret).toString(CryptoJS.enc.Hex).substring(0, 32);
}
// Generate IV
function generateIV() {
return CryptoJS.lib.WordArray.random(16).toString(CryptoJS.enc.Hex);
}
// Encrypt function
function encrypt(data, key) {
const iv = generateIV();
const cipherKey = CryptoJS.enc.Utf8.parse(deriveKey(key));
const ivHex = CryptoJS.enc.Hex.parse(iv);
const encrypted = CryptoJS.AES.encrypt(JSON.stringify(data), cipherKey, {
iv: ivHex,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
return iv + ':' + encrypted.ciphertext.toString(CryptoJS.enc.Hex);
}
// Example payload (before encryption)
const requestData = {
amount: 100,
customer_name: "customer name",
customer_email: "customer email",
customer_phone: "customer phone",
account_number: "account number",
bank_ifsc: "IFSC",
account_name: "account holder",
bank_name: "bank",
orderId: "order123",
method: "bank",
payment_mode: "IMPS"
};
// Encrypt
const encryptedData = encrypt(requestData, ENCRYPTION_KEY);
console.log(encryptedData);Step 3: Send Encrypted Request
{
"encryptedData": "iv:encrypted_string"
}Notes
- Always encrypt before sending request
- Never expose your encryption key
- Use AES-256-CBC only
Updated 10 days ago
