mirror of
https://github.com/shufflewzc/faker2.git
synced 2025-04-23 02:48:44 +08:00
Update h5st.ts
This commit is contained in:
parent
c43dd16692
commit
c5c18cf7ff
@ -1,7 +1,6 @@
|
|||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import {format} from "date-fns"
|
import {format} from "date-fns"
|
||||||
|
import * as CryptoJS from 'crypto-js'
|
||||||
const CryptoJS = require("crypto-js")
|
|
||||||
|
|
||||||
class H5ST {
|
class H5ST {
|
||||||
tk: string;
|
tk: string;
|
||||||
@ -51,7 +50,7 @@ class H5ST {
|
|||||||
this.enc = data.data.result.algo.match(/algo\.(.*)\(/)[1]
|
this.enc = data.data.result.algo.match(/algo\.(.*)\(/)[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
__genKey(tk, fp, ts, ai, algo) {
|
__genKey(tk: string, fp: string, ts: string, ai: string, algo: object) {
|
||||||
let str = `${tk}${fp}${ts}${ai}${this.rd}`;
|
let str = `${tk}${fp}${ts}${ai}${this.rd}`;
|
||||||
return algo[this.enc](str, tk)
|
return algo[this.enc](str, tk)
|
||||||
}
|
}
|
||||||
@ -59,8 +58,8 @@ class H5ST {
|
|||||||
__genH5st(body: object) {
|
__genH5st(body: object) {
|
||||||
let y = this.__genKey(this.tk, this.fp, this.timestamp, this.appId, CryptoJS).toString(CryptoJS.enc.Hex)
|
let y = this.__genKey(this.tk, this.fp, this.timestamp, this.appId, CryptoJS).toString(CryptoJS.enc.Hex)
|
||||||
let s = ''
|
let s = ''
|
||||||
for (let i in body) {
|
for (let key of Object.keys(body)) {
|
||||||
i === 'body' ? s += `${i}:${CryptoJS.SHA256(body[i]).toString(CryptoJS.enc.Hex)}&` : s += `${i}:${body[i]}&`
|
key === 'body' ? s += `${key}:${CryptoJS.SHA256(body[key]).toString(CryptoJS.enc.Hex)}&` : s += `${key}:${body[key]}&`
|
||||||
}
|
}
|
||||||
s = s.slice(0, -1)
|
s = s.slice(0, -1)
|
||||||
s = CryptoJS.HmacSHA256(s, y).toString(CryptoJS.enc.Hex)
|
s = CryptoJS.HmacSHA256(s, y).toString(CryptoJS.enc.Hex)
|
||||||
@ -70,4 +69,4 @@ class H5ST {
|
|||||||
|
|
||||||
export {
|
export {
|
||||||
H5ST
|
H5ST
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user