调用腾讯云的OCR识别时,报错了。
var CryptoJS = require( 'crypto-js' ); var now = parseInt(Date.now() / 1000), rdm = parseInt(Math.random() * Math.pow(2, 32)), plainText = 'a=' + appid + '&k=' + secretId + '&e=' + (now+pexpired) + '&t=' + now + '&r=' + rdm + userid + '&f=' , data = new Buffer(plainText, 'utf8' ), res = CryptoJS.HmacSHA1(data, secretKey); var bin = Buffer.concat([res, data]); //这一句运行时报错了 var sign = bin.toString( 'base64' ); return sign; |
|
不知道是什么原因?求解答!
var
hmac = CryptoJS.HmacSHA1(CryptoJS.enc.Utf8.parse(plainText), CryptoJS.enc.Utf8.parse(secretKey))
var
sign = CryptoJS.enc.Base64.stringify(hmac.concat(CryptoJS.enc.Utf8.parse(plainText)))
谢谢大神指导!