Commit 7138b646 by 宋毅

tj

parent 1944fcde
......@@ -136,52 +136,20 @@ class UtilsUserSve extends AppServiceBase {
*/
async getJsApiSingnature(pobj, ticket, nonce, timeStamp, url) {//获取JsApi鉴权签名信息----本类中调用
// public static String sign(String ticket, String nonceStr, long timeStamp, String url) throws OApiException {
// String plain = "jsapi_ticket=" + ticket + "&noncestr=" + nonceStr + "&timestamp=" + String.valueOf(timeStamp)
// + "&url=" + url;
// try {
// MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
// sha1.reset();
// sha1.update(plain.getBytes("UTF-8"));
// return byteToHex(sha1.digest());
// } catch (NoSuchAlgorithmException e) {
// throw new OApiResultException(e.getMessage());
// } catch (UnsupportedEncodingException e) {
// throw new OApiResultException(e.getMessage());
// }
// }
// // 字节数组转化成十六进制字符串
// private static String byteToHex(final byte[] hash) {
// Formatter formatter = new Formatter();
// for (byte b : hash) {
// formatter.format("%02x", b);
// }
// String result = formatter.toString();
// formatter.close();
// return result;
// }
let plainTex = "jsapi_ticket=" + ticket + "&noncestr=" + nonce + "&timestamp=" + timeStamp + "&url=" + url;
//1
var BufferList = new Buffer(plainTex, "UTF-8");
let signBufferList = cryptoJS.createHash('sha1').update(BufferList).digest();
let hexs = "";
for (let i = 0; i < signBufferList.length; i++) {
let hex = (signBufferList[i]).toString(16);
if (hex.length === 1) {
hexs = '0' + hex;
}
hexs += hex.toUpperCase();
}
const signature = hexs;
// var BufferList = new Buffer(plainTex, "UTF-8");
// let signBufferList = cryptoJS.SHA1(BufferList).digest();
// let hexs = "";
// for (let i = 0; i < signBufferList.length; i++) {
// let hex = (signBufferList[i]).toString(16);
// if (hex.length === 1) {
// hexs = '0' + hex;
// }
// hexs += hex.toUpperCase();
// }
// const signature = hexs;
// 2
// let signature = cryptoJS.SHA1(plainTex).toString();
......@@ -190,6 +158,12 @@ class UtilsUserSve extends AppServiceBase {
// let signature = cryptoJS.createHash('sha1').update(plainTex).digest('hex').toUpperCase();
//4
var sha1 = cryptoJS.createHash('sha1');
sha1.update(plainTex, 'utf8');
let signature = sha1.digest('hex');
this.logCtl.info({
appid: pobj.appInfo ? pobj.appInfo.uapp_id : "",
appkey: pobj.appInfo ? pobj.appInfo.uapp_key : "",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment