Skip to content

Instantly share code, notes, and snippets.

View sunpochin's full-sized avatar
💭
Where do we go from here?

Sun Pochin sunpochin

💭
Where do we go from here?
View GitHub Profile
@qrtt1
qrtt1 / 00-ITHOME 2021 鐵人賽-觀戰區.md
Last active August 2, 2024 14:39
ITHome 第 13 屆鐵人賽 (updated UTC 2021-11-07 10:14:45.317902)
@tom19960222
tom19960222 / index.js
Created June 11, 2019 04:02
ECPay generate CheckMacValue
const generateCheckMacValue = (data, hashKey, hashIV) => {
const keys = Object.keys(data).sort((l, r) => l > r);
let checkValue = '';
for(const key of keys){ checkValue += `${key}=${data[key]}&` }
checkValue = `HashKey=${hashKey}&${checkValue}HashIV=${hashIV}`; // There is already an & in the end of checkValue
checkValue = encodeURIComponent(checkValue).toLowerCase();
checkValue = checkValue.replace(/%20/g, '+')
.replace(/%2d/g, '-')
.replace(/%5f/g, '_')
.replace(/%2e/g, '.')