You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
690 B
27 lines
690 B
1 year ago
|
'use strict';
|
||
|
const CryptoJS = require('crypto-js');
|
||
|
const hmacSHA512 = require('crypto-js/hmac-sha512');
|
||
|
const Base64 = require('crypto-js/enc-base64');
|
||
|
const moment = require('moment');
|
||
|
|
||
|
const createAuthorization = () => {
|
||
|
let appid = 10009
|
||
|
let appkey = '12b1b4724b9643b89a40858000f1cd7e'
|
||
|
|
||
|
let timestamp = moment().valueOf()
|
||
|
let sb = `appid=${appid}×tamp=${timestamp}`
|
||
|
|
||
|
let digest = CryptoJS.HmacSHA1(sb, appkey)
|
||
|
|
||
|
// digest = Base64.stringify(hmacSHA512(sb, appkey))
|
||
|
|
||
|
digest = Base64.stringify(digest)
|
||
|
|
||
|
return `HmacSHA appid:${timestamp}:${digest}`
|
||
|
return `HmacSHA ${appid}:${timestamp}:${digest}`
|
||
|
}
|
||
|
|
||
|
|
||
|
module.exports = {
|
||
|
createAuthorization
|
||
|
}
|