Last active
September 13, 2019 18:05
-
-
Save thiagosouza/2f24b86421313dceb09ffa1ecf510a4d to your computer and use it in GitHub Desktop.
Swipe - node.js sdk - sign transaction
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Crypto = require("crypto-js") | |
const Base64 = require("crypto-js/enc-base64") | |
const requestPath = "/accounts" | |
const bodyString = "" | |
const secret = "71ad81f98fbbab22c9d74948d2899a65027208197291d11e2065c3a9c62fe1f0" | |
const timestamp = Math.floor(Date.now() / 1000) // "1540920260" | |
const method = "GET" | |
const stringToSign = method + timestamp + requestPath + bodyString | |
const hmac = Crypto.HmacSHA256(stringToSign, secret) | |
const signature = Base64.stringify(hmac) | |
console.log(signature) | |
// /h02U+jDJWOG1npOvL1pH79hgGWT7mWymzxISP5IphA= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment