|
@@ -481,6 +481,8 @@ import {
|
|
|
import Axios from "axios";
|
|
|
import Loading from "@/components/Loading";
|
|
|
import {saveAs} from 'file-saver';
|
|
|
+import Web3 from "web3";
|
|
|
+import CryptoJS from "crypto-js";
|
|
|
|
|
|
export default {
|
|
|
components: {Loading},
|
|
@@ -628,14 +630,67 @@ export default {
|
|
|
this.error('密码不一致')
|
|
|
return
|
|
|
}
|
|
|
- let params = this.batchAddressObj
|
|
|
+ // 要加密的数据
|
|
|
+ const dataToEncrypt = JSON.stringify(JSON.parse(this.batchAddressObj.password));
|
|
|
+ // console.log('输入的密码:', dataToEncrypt);
|
|
|
+ // 获取当前北京时间
|
|
|
+ const beijingDate = this.getCurrentBeijingTime();
|
|
|
+ // 生成keyByte
|
|
|
+ const keyByte = this.generateKeyByteArray(beijingDate);
|
|
|
+ // console.log('生成的toHex:', keyByte);
|
|
|
+ // 加密数据
|
|
|
+ const encryptedData = this.encryptData(dataToEncrypt, keyByte);
|
|
|
+ console.log('加密后的数据:', encryptedData);
|
|
|
+ let params = {
|
|
|
+ chainId : this.batchAddressObj.chainId,
|
|
|
+ groupName : this.batchAddressObj.groupName,
|
|
|
+ numWallet : this.batchAddressObj.numWallet,
|
|
|
+ password : encryptedData
|
|
|
+ }
|
|
|
this.confirmLoading = true
|
|
|
batchAddress(params).then(res=>{
|
|
|
this.addressList = res
|
|
|
this.completeGeneration = true
|
|
|
- this.confirmLoading = true
|
|
|
+ this.confirmLoading = false
|
|
|
})
|
|
|
},
|
|
|
+ // 获取当前北京时间并格式化为 YYYYMMDD
|
|
|
+ getCurrentBeijingTime() {
|
|
|
+ const localDate = new Date();
|
|
|
+ const localTime = localDate.getTime(); // 获取当前本地时间的时间戳
|
|
|
+ const localOffset = localDate.getTimezoneOffset() * 60000; // 本地时区偏移的毫秒数
|
|
|
+ const utcTime = localTime + localOffset; // 转换为 UTC 时间
|
|
|
+ const beijingOffset = 8 * 60 * 60000; // 北京时区偏移的毫秒数
|
|
|
+ const beijingTime = utcTime + beijingOffset; // 加上北京时区偏移
|
|
|
+
|
|
|
+ const beijingDate = new Date(beijingTime);
|
|
|
+ const year = beijingDate.getFullYear();
|
|
|
+ const month = (beijingDate.getMonth() + 1).toString().padStart(2, '0');
|
|
|
+ const day = beijingDate.getDate().toString().padStart(2, '0');
|
|
|
+
|
|
|
+ return `${year}${month}${day}${year}${month}${day}`;
|
|
|
+ },
|
|
|
+ // 生成
|
|
|
+ generateKeyByteArray(content) {
|
|
|
+ let bytes = [];
|
|
|
+ let len, c;
|
|
|
+ len = content.length;
|
|
|
+ for (let i = 0; i < len; i++) {
|
|
|
+ c = content[i];
|
|
|
+ bytes.push(parseInt(c))
|
|
|
+ }
|
|
|
+ // console.log('当前北京时间的数组',bytes);
|
|
|
+ return Web3.utils.bytesToHex(bytes).substring(2);
|
|
|
+ },
|
|
|
+ // 加密函数
|
|
|
+ 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()
|
|
|
+
|
|
|
+ },
|
|
|
downloadAddress(el) {
|
|
|
let groupName = this.table.walletNameGroup[this.table.walletNameGroupIndex]
|
|
|
if(el){
|