Hello,
I am running a serverscript. I want to create a SMA256 key. the bubble server returns the value that i want in the server output :
However when i try to update my database with this value, it seems that bubble say that it is empty …
Can someone help me please?
here is my code :
function generateBase64Hash() {
const crypto = require(“crypto”);
// Parameters
const params = {
vads_action_mode: "INTERACTIVE",
vads_amount: "5124",
vads_ctx_mode: "TEST",
vads_currency: "953",
vads_page_action: "PAYMENT",
vads_payment_config: "SINGLE",
vads_site_id: "12345678",
vads_trans_date: "20170129130025",
vads_trans_id: "123456",
vads_version: "V2"
};
// Sort and concatenate parameters
const sortedKeys = Object.keys(params).sort();
const concatenatedParams = sortedKeys.map(key => `${params[key]}`).join('+');
// Append the key to the concatenated string
const secretKey = "1122334455667788";
const finalString = `${concatenatedParams}+${secretKey}`;
// Generate HMAC SHA256 hash and encode in Base64
const hash = crypto.createHmac("sha256", secretKey)
.update(finalString)
.digest("base64"); // Base64 encoding for the hash
// Return the final hash
return hash;
}
// Call the function and log the result
console.log(generateBase64Hash());