var crypto = require('crypto'); var buf1 = crypto.createHmac("sha1", "0").update("shanghai").digest(); var buf2 = Buffer.from('beijing'); console.log(Buffer.concat([buf1, buf2]).toString('base64'));