巴林闲侠
1 year ago
5 changed files with 67 additions and 2 deletions
@ -0,0 +1,27 @@ |
|||
'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 |
|||
} |
Loading…
Reference in new issue