Commit c0c53508 authored by 皮倩雯's avatar 皮倩雯

fix: '修改加密方式'

parent d3411171
Pipeline #62770 waiting for manual action with stages
......@@ -38,6 +38,7 @@ import {
InitAddDataBase, // 数据库初始化
InitEditDataBase, // 二次初始化
} from '@/services/database/api';
import CryptoJS from 'crypto-js';
import styles from './InitDataBase.less';
import InitModal from './initModal';
......@@ -85,6 +86,8 @@ const InitDataBase = props => {
const [keep, setKeep] = useState([]);
const [flag, setFlag] = useState(0);
const [keepData, setKeepData] = useState({});
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 获取数据库配置信息
useEffect(() => {
......@@ -102,8 +105,13 @@ const InitDataBase = props => {
obj[k] = res[k];
});
console.log(obj, 'objohjfaosdjf');
form.setFieldsValue({ ...obj, password: atob(obj.password) });
setDbForm(val => ({ ...val, ...obj, password: atob(obj.password) }));
console.log(Decrypt(obj.password));
let aa = Decrypt(obj.password);
console.log(Encrypt(aa));
form.setFieldsValue({ ...obj, password: Decrypt(obj.password) });
setDbForm(val => ({ ...val, ...obj, password: Decrypt(obj.password) }));
setAllSqulDir(res.allSqlDir);
if (res.allSqlDir.some(item => item === inUse)) {
setDefaultSqlDir(res.tableSQLDirName);
......@@ -121,6 +129,31 @@ const InitDataBase = props => {
}
};
}, []);
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
//加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 弹出模态框
const handleShowModal = (key, value) => {
setModalVisible({ ...modalVisible, [key]: value });
......@@ -226,7 +259,7 @@ const InitDataBase = props => {
ip: obj.ip,
dbName: obj.dbName,
userName: obj.userName,
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(resnew => {
setCardLoading(false);
......@@ -236,7 +269,7 @@ const InitDataBase = props => {
ip: obj.ip,
dbName: obj.dbName,
userName: obj.userName,
password: btoa(obj.password),
password: Encrypt(obj.password),
});
// setUpData(upData + 1);
getConnRecordData();
......@@ -269,7 +302,7 @@ const InitDataBase = props => {
ip: obj.ip,
dbName: obj.dbName,
userName: obj.userName,
password: btoa(obj.password),
password: Encrypt(obj.password),
// Type:"SQLServer",
// name:obj.dbName,
})
......@@ -302,7 +335,7 @@ const InitDataBase = props => {
// _version: 9999,
// _dc: Date.now(),
userName: params.userName || '',
password: btoa(params.password) || '',
password: Encrypt(params.password) || '',
ip: params.ip || '',
})
.then(res => {
......@@ -328,7 +361,7 @@ const InitDataBase = props => {
Object.keys(obj).forEach(k => {
obj[k] = item[k];
});
form.setFieldsValue({ ...obj, password: atob(obj.password) });
form.setFieldsValue({ ...obj, password: Decrypt(obj.password) });
};
// 产品方案选择框回调
const handleSelect = value => {
......@@ -385,7 +418,7 @@ const InitDataBase = props => {
ip: obj.ip,
dbName: obj.dbName,
userName: obj.userName,
password: btoa(obj.password),
password: Encrypt(obj.password),
desc,
})
.then(res => {
......@@ -431,7 +464,7 @@ const InitDataBase = props => {
const GetDb = () => {
let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: btoa(obj.password) }).then(res => {
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => {
if (res.code === 0) {
console.log(res.data);
if (res.data.Product) {
......@@ -473,7 +506,7 @@ const InitDataBase = props => {
setInitLoading(true);
let obj = form.getFieldsValue();
let req1 = GetProductList();
let req2 = GetDbProduct({ ...obj, password: btoa(obj.password) });
let req2 = GetDbProduct({ ...obj, password: Encrypt(obj.password) });
Promise.all([req1, req2])
.then(res => {
if (res[1].code !== 0 || res[0].code !== 0) {
......@@ -620,24 +653,27 @@ const InitDataBase = props => {
setInitVisible(true);
doInitLog();
if (dbExists) {
InitEditDataBase({ ...obj, productSetting, license: j, password: btoa(obj.password) }).then(
res => {
setInitLoading(false);
if (res.code === 0) {
notification.success({
message: '提示',
duration: 3,
description: '数据库初始化成功',
});
} else {
notification.error({
message: '提示',
duration: 5,
description: res.msg,
});
}
},
);
InitEditDataBase({
...obj,
productSetting,
license: j,
password: Encrypt(obj.password),
}).then(res => {
setInitLoading(false);
if (res.code === 0) {
notification.success({
message: '提示',
duration: 3,
description: '数据库初始化成功',
});
} else {
notification.error({
message: '提示',
duration: 5,
description: res.msg,
});
}
});
return;
}
InitAddDataBase({ ...obj, productSetting, license: j }).then(res => {
......
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification } from 'antd';
import { AddConnString, EditConnString } from '@/services/database/api';
import CryptoJS from 'crypto-js';
const { Item } = Form;
const { Option } = Select;
......@@ -8,6 +9,33 @@ const AddModal = props => {
const { callBackSubmit = () => {}, type, formObj, visible } = props;
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
......@@ -18,7 +46,7 @@ const AddModal = props => {
AddConnString({
type: 'mysql',
...obj,
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -54,7 +82,7 @@ const AddModal = props => {
type: 'mysql',
...obj,
oldName: formObj.name,
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -84,7 +112,7 @@ const AddModal = props => {
form.setFieldsValue({ port: 3306 });
break;
case 'edit':
form.setFieldsValue({ ...formObj, password: atob(formObj.password) });
form.setFieldsValue({ ...formObj, password: Decrypt(formObj.password) });
if (!formObj.port) {
form.setFieldsValue({ port: 3306 });
}
......
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification } from 'antd';
import { AddConnString, EditConnString } from '@/services/database/api';
import CryptoJS from 'crypto-js';
const { Item } = Form;
const { Option } = Select;
......@@ -8,6 +9,33 @@ const AddModal = props => {
const { callBackSubmit = () => {}, type, formObj, visible } = props;
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
......@@ -18,7 +46,7 @@ const AddModal = props => {
AddConnString({
...obj,
type: 'oracle',
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -54,7 +82,7 @@ const AddModal = props => {
type: 'oracle',
...obj,
oldName: formObj.name,
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -83,7 +111,7 @@ const AddModal = props => {
form.resetFields();
break;
case 'edit':
form.setFieldsValue({ ...formObj, password: atob(formObj.password) });
form.setFieldsValue({ ...formObj, password: Decrypt(formObj.password) });
break;
default:
break;
......
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, notification } from 'antd';
import { AddConnString, EditConnString } from '@/services/database/api';
import CryptoJS from 'crypto-js';
const { Item } = Form;
const { Option } = Select;
......@@ -8,6 +9,33 @@ const AddModal = props => {
const { callBackSubmit = () => {}, type, formObj, visible } = props;
const [loading, setLoading] = useState(false);
const [form] = Form.useForm();
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
......@@ -18,7 +46,7 @@ const AddModal = props => {
AddConnString({
...obj,
type: 'sqlserver',
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -54,7 +82,7 @@ const AddModal = props => {
...obj,
oldName: formObj.name,
type: 'sqlserver',
password: btoa(obj.password),
password: Encrypt(obj.password),
})
.then(res => {
setLoading(false);
......@@ -83,7 +111,7 @@ const AddModal = props => {
form.resetFields();
break;
case 'edit':
form.setFieldsValue({ ...formObj, password: atob(formObj.password) });
form.setFieldsValue({ ...formObj, password: Decrypt(formObj.password) });
break;
default:
break;
......
......@@ -10,6 +10,7 @@ import {
CheckOutlined,
} from '@ant-design/icons';
import styles from './DatabaseInitialization.less';
import CryptoJS from 'crypto-js';
import { GetLicenseDifference, InitEditDataBase, GetProductList } from '@/services/database/api';
const AppendModal = props => {
......@@ -29,6 +30,9 @@ const AppendModal = props => {
const [number1, setNumber1] = useState('');
const [allValue, setAllValue] = useState([]);
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
useEffect(() => {
if (visible) {
getProduct();
......@@ -65,9 +69,33 @@ const AppendModal = props => {
}
}, [visible]);
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
const getProduct = () => {
setLoading(true);
GetLicenseDifference({ ...value, password: btoa(value.password) }).then(res => {
GetLicenseDifference({ ...value, password: Encrypt(value.password) }).then(res => {
setLoading(false);
if (res.code === 0) {
let aab = [];
......
......@@ -49,6 +49,7 @@ import {
PlusOutlined,
EyeOutlined,
} from '@ant-design/icons';
import CryptoJS from 'crypto-js';
import styles from './DatabaseInitialization.less';
import styles1 from '../InitDataBase/InitDataBase.less';
import AppendModal from './AppendModal';
......@@ -122,6 +123,33 @@ const DatabaseInitialization = props => {
const [historyVisible, setHistoryVisible] = useState(false);
const [keepInitDetailVisible, setKeepInitDetailVisible] = useState(false);
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); //十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
//加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 获取数据库配置信息
useEffect(() => {
setCardLoading(true);
......@@ -337,7 +365,7 @@ const DatabaseInitialization = props => {
ip: resdata.data.ip,
dbName: resdata.data.dbName,
userName: resdata.data.userName,
password: atob(resdata.data.password),
password: Decrypt(resdata.data.password),
});
GetDbChangeFirst(kk);
// 有License的情况下首次进入展示数据
......@@ -411,7 +439,7 @@ const DatabaseInitialization = props => {
const GetDbChangeFirst = kk => {
let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: btoa(obj.password) }).then(res => {
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.IsAuthorize) {
......@@ -461,7 +489,7 @@ const DatabaseInitialization = props => {
const GetDbChange = e => {
let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: btoa(obj.password) }).then(res => {
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.IsAuthorize) {
......@@ -472,19 +500,29 @@ const DatabaseInitialization = props => {
onCheckLaster(res.data.IsAppend);
}
} else {
if (
res.data.Project &&
res.data.Project[0] &&
res.data.Project[res.data.Project.length - 1].license == '已使用'
) {
setbeforeColor('red');
setResult('未检测到可用License');
setMsg('未检测到可用License');
} else {
setbeforeColor('red');
setResult('未检测到License');
setMsg('未检测到License');
}
let obj1 = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj1, password: Encrypt(obj.password) }).then(res1 => {
setCardLoading(false);
if (res1.code === 0) {
if (
res1.data.Project &&
res1.data.Project[0] &&
res1.data.Project[res1.data.Project.length - 1].license == '已使用'
) {
setbeforeColor('red');
setResult('未检测到可用License');
setMsg('未检测到可用License');
} else {
setbeforeColor('red');
setResult('未检测到License');
setMsg('未检测到License');
}
} else {
setbeforeColor('red');
setResult(`${res1.msg}`);
setMsg(res1.msg);
}
});
}
if (res.data.Project && res.data.Project.length > 0) {
setKeepHistroy(res.data.Project);
......@@ -563,7 +601,7 @@ const DatabaseInitialization = props => {
const GetDbChangeAppend = () => {
let obj = form.getFieldsValue();
GetDbProduct({ ...obj, password: btoa(obj.password) }).then(res => {
GetDbProduct({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
if (res.data.Product) {
......@@ -643,7 +681,7 @@ const DatabaseInitialization = props => {
handleShowModal('initVisible', false);
setInitVisible(true);
doInitLog();
NewInitAddDataBase({ ...obj, productSetting, password: btoa(obj.password) }).then(res => {
NewInitAddDataBase({ ...obj, productSetting, password: Encrypt(obj.password) }).then(res => {
if (res.code === 0) {
GetDbChangeAppend();
setMsg('未检测到可用License');
......@@ -697,7 +735,7 @@ const DatabaseInitialization = props => {
setInitVisible(true);
doInitLog();
let obj = form.getFieldsValue();
InitEditDataBase({ ...obj, password: btoa(obj.password) }).then(res => {
InitEditDataBase({ ...obj, password: Encrypt(obj.password) }).then(res => {
if (res.code === 0) {
GetDbChangeAppend();
setMsg('未检测到可用License');
......@@ -798,7 +836,7 @@ const DatabaseInitialization = props => {
// setKeepValue([]);
setProduct([]);
setCardLoading(true);
GetProductList({ ...obj, password: btoa(obj.password) }).then(res => {
GetProductList({ ...obj, password: Encrypt(obj.password) }).then(res => {
if (res.code === 0) {
console.log(res.data);
GetDbChange();
......@@ -827,10 +865,23 @@ const DatabaseInitialization = props => {
setMsg('请输入完整数据库信息');
}
};
// 非授权模式下环境检查
const checkUnLicense = () => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code !== 0) {
setbeforeColor('red');
setResult(`${res.msg}`);
setMsg(res.msg);
}
});
};
const onCheckLaster = aa => {
// 此时有授权码才能进入
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: btoa(obj.password) }).then(res => {
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code == 0) {
setDataValue(form.getFieldsValue());
......@@ -870,7 +921,7 @@ const DatabaseInitialization = props => {
const Submit = () => {
let obj = form.getFieldsValue();
if (obj.ip && obj.userName && obj.password && obj.dbName) {
GetProductList({ ...obj, password: btoa(obj.password) }).then(res => {
GetProductList({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
GetDbChange(1);
......@@ -900,7 +951,7 @@ const DatabaseInitialization = props => {
const findCheck = aa => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: btoa(obj.password) }).then(res => {
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
setDataValue(form.getFieldsValue());
......@@ -947,7 +998,7 @@ const DatabaseInitialization = props => {
const findCheck1 = aa => {
let obj = form.getFieldsValue();
CheckDatabaseIsExist({ ...obj, password: btoa(obj.password) }).then(res => {
CheckDatabaseIsExist({ ...obj, password: Encrypt(obj.password) }).then(res => {
setCardLoading(false);
if (res.code === 0) {
setDataValue(form.getFieldsValue());
......
import React, { useState, useEffect } from 'react';
import { Form, Modal, Input, Select, AutoComplete, Button, notification } from 'antd';
import CryptoJS from 'crypto-js';
import styles from '../SchemeConfig.less';
import { GetGISServerMapList, publisService } from '@/services/webConfig/api';
......@@ -19,6 +20,33 @@ const AddModal = props => {
const [gsIp, setGsIp] = useState([]);
const [form] = Form.useForm();
const { Item } = Form;
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
// 提交
const onSubmit = () => {
form.validateFields().then(validate => {
......@@ -33,7 +61,7 @@ const AddModal = props => {
gsAppName: obj.servicename,
gsUser: obj.user,
gsWorkspaceName: obj.workname,
gsPwd: btoa(obj.password),
gsPwd: Encrypt(obj.password),
mapServerName: obj.name,
solution: solutionNames,
};
......
import React, { useState, useEffect } from 'react';
import { Button, Descriptions, Input, Card, Divider, Row, Col } from 'antd';
import CryptoJS from 'crypto-js';
import styles from './BaseConfig.less';
import { GetDataBaseConfig, GetBasicInfo } from '@/services/hostmanager/hostmanager';
import servie from '../../../../assets/images/icons/服务器管理.svg';
......@@ -14,6 +15,33 @@ const BaseConfig = () => {
});
const [currentSiteInfo, setcurrentSiteInfo] = useState('');
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
useEffect(() => {
getCurrentConfig();
getSiteCode();
......@@ -35,8 +63,9 @@ const BaseConfig = () => {
};
const encrypt = word => {
let aa = Decrypt(word);
let encryptStr = '';
for (let i = 0; i < word.length; i++) {
for (let i = 0; i < aa.length; i++) {
encryptStr += '*';
}
return encryptStr;
......
......@@ -9,6 +9,7 @@ import {
} from '@/services/hostmanager/hostmanager';
import { GetMessageVersion } from '@/services/messagemanage/messagemanage';
import { CloseCircleFilled } from '@ant-design/icons';
import CryptoJS from 'crypto-js';
import message11 from '../../../../assets/images/icons/消息.svg';
import Yes from '../../../../assets/images/icons/正确.svg';
import styles from './messageConfig.less';
......@@ -31,6 +32,33 @@ const MessageConfig = () => {
const [flag, setFlag] = useState(0);
const [form] = Form.useForm();
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
const onFinish = values => {
// 先测试连接再保存
// 1.测试链接
......@@ -39,7 +67,7 @@ const MessageConfig = () => {
messAddress: values.messageAddress,
sqlServerIP: currentDataBase.ip,
loginName: currentDataBase.userName,
password: btoa(currentDataBase.password),
password: Encrypt(currentDataBase.password),
sqlName: currentDataBase.dbName,
siteCode: currentSiteInfo,
}).then(res => {
......@@ -72,7 +100,7 @@ const MessageConfig = () => {
messAddress: CurrentAddress,
sqlServerIP: CurrentDataBase.ip,
loginName: CurrentDataBase.userName,
password: btoa(CurrentDataBase.password),
password: Encrypt(CurrentDataBase.password),
sqlName: CurrentDataBase.dbName,
siteCode: currentSiteInfo,
}).then(res => {
......@@ -105,7 +133,7 @@ const MessageConfig = () => {
GetDataBaseConfig().then(resdata => {
if (resdata.code === 0) {
setCurrentDataBase({ ...resdata.data, password: atob(resdata.data.password) });
setCurrentDataBase({ ...resdata.data, password: Decrypt(resdata.data.password) });
GetBasicInfo().then(reslist => {
if (reslist.code === 0) {
setcurrentSiteInfo(reslist.data);
......
......@@ -5,6 +5,7 @@
/* eslint-disable react/jsx-no-undef */
import React, { useEffect, useState } from 'react';
import { Form, Modal, Row, Col, Input, Select, notification } from 'antd';
import CryptoJS from 'crypto-js';
import { addInsertVideoConfig, editInsertVideoConfig } from '@/services/videoManger/videoManger';
const AddModal = props => {
......@@ -20,8 +21,36 @@ const AddModal = props => {
const [selectChange2, setSelectChange2] = useState('主码流');
const [load, setLoad] = useState(false); // 提交加载
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
const [configurationType, setConfigurationType] = useState('1');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
const onChange = value => {
setSelectChange(value);
};
......@@ -55,8 +84,8 @@ const AddModal = props => {
getValue.StreamType = '主码流';
}
getValue.VideoManufacturer = Type;
addInsertVideoConfig({ ...getValue, LoginPwd: btoa(getValue.LoginPwd) }).then(res => {
console.log(getValue.LoginPwd)
addInsertVideoConfig({ ...getValue, LoginPwd: Encrypt(getValue.LoginPwd) }).then(res => {
if (res.msg === 'Ok') {
onCancel();
setLoad(false);
......
......@@ -2,6 +2,7 @@
import React, { useEffect, useState } from 'react';
import { Form, Modal, Row, Col, Input, Select, notification } from 'antd';
import { addInsertVideoConfig, editInsertVideoConfig } from '@/services/videoManger/videoManger';
import CryptoJS from 'crypto-js';
const AddDHModal = props => {
const { callBackSubmit = () => {}, visible, onCancel, type, kind, obj } = props;
......@@ -15,6 +16,33 @@ const AddDHModal = props => {
const [selectChange2, setSelectChange2] = useState('主码流');
const [load, setLoad] = useState(false); // 提交加载
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
const onChange = value => {
setSelectChange(value);
};
......@@ -28,11 +56,12 @@ const AddDHModal = props => {
};
useEffect(() => {
console.log(obj.LoginPwd);
setLoad(false);
if (kind === 'add') {
form.resetFields();
} else {
form.setFieldsValue({ ...obj, LoginPwd: obj.LoginPwd ? atob(obj.LoginPwd) : '' });
form.setFieldsValue({ ...obj, LoginPwd: obj.LoginPwd ? Decrypt(obj.LoginPwd) : '' });
}
}, [visible]);
const onSubmit = () => {
......@@ -52,7 +81,7 @@ const AddDHModal = props => {
}
getValue.VideoManufacturer = type;
if (kind === 'add') {
addInsertVideoConfig({ ...getValue, LoginPwd: btoa(getValue.LoginPwd) }).then(res => {
addInsertVideoConfig({ ...getValue, LoginPwd: Encrypt(getValue.LoginPwd) }).then(res => {
if (res.msg === 'Ok') {
onCancel();
setLoad(false);
......@@ -77,7 +106,7 @@ const AddDHModal = props => {
editInsertVideoConfig({
...getValue,
Id: obj.Id,
LoginPwd: btoa(getValue.LoginPwd),
LoginPwd: Encrypt(getValue.LoginPwd),
}).then(res => {
if (res.msg === 'Ok') {
onCancel();
......
import React, { useEffect, useState } from 'react';
import { Form, Modal, Row, Col, Input, Select, notification } from 'antd';
import { addInsertVideoConfig, editInsertVideoConfig } from '@/services/videoManger/videoManger';
import CryptoJS from 'crypto-js';
const AddHKModal = props => {
const { callBackSubmit = () => {}, visible, onCancel, type, kind, obj } = props;
......@@ -14,6 +15,33 @@ const AddHKModal = props => {
const [selectChange2, setSelectChange2] = useState('主码流');
const [load, setLoad] = useState(false); // 提交加载
const key = CryptoJS.enc.Utf8.parse('1p2a3n4d5a6o7m8s9a10n1e2t3c4o5re'); // 十六位十六进制数作为密钥
const iv = CryptoJS.enc.Utf8.parse('1234567890000000');
// 解密
const Decrypt = word => {
let encryptedHexStr = CryptoJS.enc.Hex.parse(word);
let srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
let decrypt = CryptoJS.AES.decrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
return decryptedStr.toString();
};
// 加密
const Encrypt = word => {
let srcs = CryptoJS.enc.Utf8.parse(word);
let encrypted = CryptoJS.AES.encrypt(srcs, key, {
iv,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7,
});
return encrypted.ciphertext.toString().toUpperCase();
};
const onChange = value => {
setSelectChange(value);
};
......@@ -27,11 +55,12 @@ const AddHKModal = props => {
};
useEffect(() => {
console.log(obj.LoginPwd);
setLoad(false);
if (kind === 'add') {
form.resetFields();
} else {
form.setFieldsValue({ ...obj, LoginPwd: obj.LoginPwd ? atob(obj.LoginPwd) : '' });
form.setFieldsValue({ ...obj, LoginPwd: obj.LoginPwd ? Decrypt(obj.LoginPwd) : '' });
}
}, [visible]);
const onSubmit = () => {
......@@ -51,7 +80,7 @@ const AddHKModal = props => {
}
getValue.VideoManufacturer = type;
if (kind === 'add') {
addInsertVideoConfig({ ...getValue, LoginPwd: btoa(getValue.LoginPwd) }).then(res => {
addInsertVideoConfig({ ...getValue, LoginPwd: Encrypt(getValue.LoginPwd) }).then(res => {
if (res.msg === 'Ok') {
onCancel();
setLoad(false);
......@@ -76,7 +105,7 @@ const AddHKModal = props => {
editInsertVideoConfig({
...getValue,
Id: obj.Id,
LoginPwd: btoa(getValue.LoginPwd),
LoginPwd: Encrypt(getValue.LoginPwd),
}).then(res => {
if (res.msg === 'Ok') {
onCancel();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment