Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nodejs Signature process example with dummy values
const apiKey = '825805c3-45d6-4fab-9b05-0844395ff3ef';
const privateKey = `-----BEGIN ENCRYPTED PRIVATE KEY-----
MIIC3TBXBgkqhkiG9w0BBQ0wSjApBgkqhkiG9w0BBQwwHAQIgiEmpW3i8ccCAggA
MAwGCCqGSIb3DQIJBQAwHQYJYIZIAWUDBAEqBBDtIerHEx69L1zC6FG3UDJ6BIIC
gJ/cU/utsW6FuQ3QFvQjOLyeErn18p8Jer/v1ejLEuZ741h3Tt79MjlvHkAfL+4r
mUQbO+MotpzoehI7oKfdSvC8Vi6x6R9QRmr4PLtUaUZrbM82ZwvWpaVqoSRAnL+r
Xvsyy7bNRyCjbPmMd+x3c111Q3ZVJro+3p89n/x3R987vM+J7+wabgRhntlSMB1p
I+cbesfJaQPbZ+qYAreef2Tzy4gk0NJOwNhjWjvICBsaZI8sxNwDmA3sZ01nkh9g
GC8yBIgJsPaMoix7wvTScd+5YFXlNO5EWWndeD6eNt1c2ui7UdmvOhGND+s9I2b/
G6I1agW7vyd3M6MO4BBDqHk0BxQ20J4ORRuBvGFPfHScMCbAdd2SrKxD0GZd6F/n
J9hyBF3NEsL8U8uXZ/XHUHzALbYHCPpdlEVHwPatdHmw5g/iZDO2xaeNxDvBKhxN
/d7P1O3By2QVowkO4Carv7er0U9gEiYPpP8QNSEEbgAcKue+weU+atbEeKf9lNIz
dsik1kHZWRlLYq4IxnNxXvMsXhrVZT019uJvY5kfaeHatHpCoSdhXqXJ2F6nHUc/
4FsoKGVvA5wB248slueZgJX/khPPbYAWANbK9R5WzJefr+RUrhieCoNksvHm0Bew
EFz8H5AzW197eRtVtSvFGAS+3rhV/vG9WBtoOR0FgmkN9xpzJnb9j6Svwf9NKlds
pK7f+JVmZy6NaEBJvGQAvLWHc9Jc0PxvmIgc3vaPxl+l+AITS7kN3EORyDrdvJ9q
8hP6slgnVaHcgEJSUhSyD+yustfNUfH7Fg3rUM2nvkI+8Sj0yETijFUK8qRKCUqC
8LK0+5s/6170jW5C5BPO/qM=
-----END ENCRYPTED PRIVATE KEY-----`;
const nonce = '4d479ae7-1e03-4a77-89ff-ff8354f49efb';
const timestamp = 1583416927547; // Result of `Date.now()`
const {createSign} = require('crypto');
const signer = createSign('sha256');
signer.update(`4d479ae7-1e03-4a77-89ff-ff8354f49efb1583416927547`); // Result of `${nonce}${timestamp}`
const signature = signer.sign({key:privateKey , passphrase: ''}, 'base64');
/* Your `signature` should be:
qDS6zC0PPQAuro5OtF+XhZYssd0GxFktv4G0O4OkrKs+UH2kPwlOYQM6Y1HQEJDJbykZjvlzNRg67LyxXw1svkyg90HM+l0odes8RIivK6cVMHlFOYvJlOObDiQOGmhkloAyLZ7vtj4L5paDDK8NSU2zLa8rcQp5lREtq59b65M=
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment