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
| import CryptoJS from 'crypto-js' | |
| const GDAX_SECRET = 'PYPd1Hv4J6/7x...'; | |
| const getGdaxSignature = (endpoint, body = '') => { | |
| const timestamp = Date.now() / 1000; | |
| const body = JSON.stringify(body); | |
| const message = timestamp + method + endpoint + body; // create prehash string by concatenating required parts | |
| const key = CryptoJS.enc.Base64.parse(GDAX_SECRET); // Base64 decode the alphanumeric secret string | |
| const signedMessage = CryptoJS.HmacSHA256(message, key); // use it as key for SHA 256 HMAC |