|
@@ -919,6 +919,7 @@ import {getGroupList} from "@/api/adress";
|
|
|
import {getInteractionRecord, retryFailed} from "@/api/record";
|
|
|
import {projectPage} from "@/api/project";
|
|
|
import CryptoJS from "crypto-js";
|
|
|
+import Web3 from 'web3'
|
|
|
|
|
|
export default {
|
|
|
data() {
|
|
@@ -1043,15 +1044,14 @@ export default {
|
|
|
batchExecutionTask() {
|
|
|
// 要加密的数据
|
|
|
const dataToEncrypt = this.password;
|
|
|
+ console.log('输入的密码:', dataToEncrypt);
|
|
|
// 获取当前北京时间
|
|
|
const beijingDate = this.getCurrentBeijingTime();
|
|
|
- // 生成字节数组
|
|
|
- const keyByteArray = this.generateKeyByteArray(beijingDate);
|
|
|
+ // 生成keyByte
|
|
|
+ const keyByte = this.generateKeyByteArray(beijingDate);
|
|
|
+ console.log('生成的toHex:', keyByte);
|
|
|
// 加密数据
|
|
|
- const encryptedData = this.encryptData(dataToEncrypt, keyByteArray);
|
|
|
- console.log('输入的密码:', dataToEncrypt);
|
|
|
- console.log('当前北京时间:', beijingDate);
|
|
|
- console.log('生成的字节数组(密钥):', keyByteArray);
|
|
|
+ const encryptedData = this.encryptData(dataToEncrypt, keyByte);
|
|
|
console.log('加密后的数据:', encryptedData);
|
|
|
|
|
|
this.batchExecutionParams.password = encryptedData
|
|
@@ -1078,44 +1078,26 @@ export default {
|
|
|
|
|
|
return `${year}${month}${day}${year}${month}${day}`;
|
|
|
},
|
|
|
- // 生成字节数组(密钥)
|
|
|
+ // 生成
|
|
|
generateKeyByteArray(content) {
|
|
|
- // 创建 TextEncoder 对象
|
|
|
- // const encoder = new TextEncoder();
|
|
|
- // 将字符串转换为 Uint8Array 字节数组
|
|
|
- // return encoder.encode(content)
|
|
|
- // return CryptoJS.enc.Utf8.parse(content).words
|
|
|
let bytes = [];
|
|
|
let len, c;
|
|
|
len = content.length;
|
|
|
for (let i = 0; i < len; i++) {
|
|
|
- c = content.charCodeAt(i);
|
|
|
- if (c >= 0x010000 && c <= 0x10FFFF) {
|
|
|
- bytes.push(((c >> 18) & 0x07) | 0xF0);
|
|
|
- bytes.push(((c >> 12) & 0x3F) | 0x80);
|
|
|
- bytes.push(((c >> 6) & 0x3F) | 0x80);
|
|
|
- bytes.push((c & 0x3F) | 0x80);
|
|
|
- } else if (c >= 0x000800 && c <= 0x00FFFF) {
|
|
|
- bytes.push(((c >> 12) & 0x0F) | 0xE0);
|
|
|
- bytes.push(((c >> 6) & 0x3F) | 0x80);
|
|
|
- bytes.push((c & 0x3F) | 0x80);
|
|
|
- } else if (c >= 0x000080 && c <= 0x0007FF) {
|
|
|
- bytes.push(((c >> 6) & 0x1F) | 0xC0);
|
|
|
- bytes.push((c & 0x3F) | 0x80);
|
|
|
- } else {
|
|
|
- bytes.push(c & 0xFF);
|
|
|
- }
|
|
|
+ c = content[i];
|
|
|
+ bytes.push(parseInt(c))
|
|
|
}
|
|
|
- return bytes;
|
|
|
+ console.log('当前北京时间的数组',bytes);
|
|
|
+ return Web3.utils.bytesToHex(bytes).substring(2);
|
|
|
},
|
|
|
// 加密函数
|
|
|
- encryptData(data, key) {
|
|
|
- const encrypted = CryptoJS.AES.encrypt(data, key, {
|
|
|
- mode: CryptoJS.mode.ECB,
|
|
|
- padding: CryptoJS.pad.Pkcs7
|
|
|
- });
|
|
|
+ encryptData(word, keyStr) {
|
|
|
+ let key = CryptoJS.enc.Hex.parse(keyStr)
|
|
|
+ console.log('CryptoJS生成的key',key);
|
|
|
+ let encrypted = CryptoJS.AES.encrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7}) // 加密模式为ECB,补码方式为PKCS5Padding(也就是PKCS7)
|
|
|
+
|
|
|
+ return encrypted.toString()
|
|
|
|
|
|
- return encrypted.toString();
|
|
|
},
|
|
|
viewTaskDetails(item) {
|
|
|
this.currentTaskInfo = JSON.parse(JSON.stringify(item))
|