Libraries
The following packages are included:
- moment - convert timestamps into date and time
- moment_timezone - timezone aware
- crypto - functions to sign requests, etc.
- mqtt
crypto
function generateHMAC(data, secret) {
const hmac = crypto.createHmac('sha256', secret);
hmac.update(data);
return hmac.digest('hex');
}
function generateHash(data) {
const hash = crypto.createHash('sha256');
hash.update(data);
return hash.digest('hex');
}
// HMAC Example
let data = 'myDataToHMAC';
let secret = 'mySecretKey';
let hashedData = generateHash(data);
let hmacResult = generateHMAC(data, secret);
console.log(hashedData);
list of all the available crypto commands
console.log(Object.keys(crypto));
Updated 3 months ago