扣出来 代码段如下
[JavaScript] 纯文本查看 复制代码 async init(e, t) {
try {
this.isStop = !1,
this.isCancel = !1,
qi.initLog();
let n = await this.dispatch({
...this.options.dispatchParams,
...e
});
if (!n)
return;
this.currFile = this.fileList[0];
let r = this.currFile;
if (r.progress = [],
r.sliceInfo = [],
r.time = {},
"podcast_audio" === this.options.default.type) {
const e = await _a(r);
console.log("audio", e),
this.emit("screenshot", {
detail: e
})
}
console.log(this.options, "xxx"),
r.hash = zi.hash(`${r.lastModified}|${r.size}|${r.name}|${this.options.default.type}`),
r.session_id = zi.hash(`${r.lastModified}|${r.size}|${r.name}|${this.options.default.type}|${dt().unix()}`),
qi.updateLog({
file_length: r.size,
filename: r.name
});
let i = localStorage.getItem("wbUploader");
if (this.isCancel)
return;
然后帮我构造js函数session_id 并模拟将 各个参数支持js运行
大概清楚是哈希算法 最后修改时间lastModified +文件视频的大小+文件名称+文件类型+到文本(dt().unix())
最后是赋值给了 session_id
我用ai写了但是放到精易助手 不行
以下为ai写的
[JavaScript] 纯文本查看 复制代码 // 引入必要的库
const { createHash } = require('crypto'); // 引入加密库
// 模拟的文件对象和选项对象
const file = {
lastModified: new Date().getTime(), // 文件最后修改时间(毫秒)
size: 1024 * 1024 * 5, // 文件大小(5MB)
name: 'example.txt' // 文件名称
};
const options = {
default: {
type: 'document' // 默认类型
}
};
// 模拟的 dt 函数(假设返回当前时间的 Unix 时间戳)
function dt() {
return {
unix: () => Math.floor(Date.now() / 1000)
};
}
// 模拟的 zi.hash 函数(使用 SHA-256 哈希算法)
const zi = {
hash: (data) => {
const hash = createHash('sha256');
hash.update(data);
return hash.digest('hex');
}
};
// 构造 session_id 的函数
function generateSessionId(file, options) {
const r = file;
const hashData = `${r.lastModified}|${r.size}|${r.name}|${options.default.type}|${dt().unix()}`;
return zi.hash(hashData);
}
// 测试生成 session_id
const sessionId = generateSessionId(file, options);
console.log('Generated Session ID:', sessionId);
在线求个js高手帮我改下 支持易语言直接运行的源码
|