This commit is contained in:
luying
2022-04-02 17:43:12 +08:00
parent f50c32079c
commit 89744aeb13
11 changed files with 193 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { REDIS_KEY, SDK_37_ADDR, SDK_37_CONST } from '../consts';
import { REDIS_KEY, SDK_37_ADDR, SDK_37_CONST, WJX_KEY } from '../consts';
import { request37 } from './httpUtil';
import { nowSeconds } from './timeUtil';
import { LoginValidataReturn37, Chat37Params, GetServerListParam } from '../domain/sdk';
@@ -12,6 +12,12 @@ export function md5(str: string, treatStr?: (str: string) => string) {
return crypto.createHash('md5').update(str, 'utf8').digest("hex");
};
export function sha1(str: string, treatStr?: (str: string) => string) {
if(treatStr) str = treatStr(str);
// console.log('*****str', str)
return crypto.createHash('sha1').update(str, 'utf8').digest("hex");
}
export function getMd5ObjSign(obj: any, joinMark: string, treatStr?: (str: string) => string) {
const str = [];
Object.keys(obj).sort().forEach((key) => {
@@ -36,7 +42,6 @@ export async function checkMd5Sign(obj: any, treatStr?: (str: string) => string)
return false;
}
/************** 37sdk **************/
export function get37Md5SignA(body: any, key: string) {
@@ -123,4 +128,14 @@ function treatVid(str) {
export function getRedisSubChannel(key: REDIS_KEY, env: string) {
return `${key}:${env}`;
}
/********* 问卷星加密 *********/
export function checkWjxSign(activity: string, index: string, sign: string) {
const str = `${activity}${index}${WJX_KEY}`;
let signResult = sha1(str);
console.log('##### checkWjxSign', str, signResult, sign);
if(signResult != sign) return false;
return true;
}