提交 05a47c94 authored 作者: 钟是志's avatar 钟是志

鉴权加密修改

上级 1f186a3a
...@@ -7,22 +7,75 @@ ...@@ -7,22 +7,75 @@
import { getToken } from '@/webPublic/one_stop_public/utils/getToken'; import { getToken } from '@/webPublic/one_stop_public/utils/getToken';
import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON'; import { isJSON } from '@/webPublic/one_stop_public/2022beidianke/isJSON';
import { strToBinary } from '@/webPublic/one_stop_public/Base16/strToBinary';
import { getHeaders } from '@/webPublic/zyd_public/utils/getHeaders';
function getApi(apiUrl) {
const data = {
url: apiUrl,
token: getToken(),
};
console.log(JSON.stringify(data));
const datasCode = strToBinary(JSON.stringify(data));
console.log(datasCode);
let file = new File([datasCode], 'fileParams.jpeg', {
type: 'image/jpeg',
});
export function getTransformApi(url = '') { let datasTrue = {
let t = getToken(); fileParams: file,
if (!t || t.length < 11) { bin: true,
rbin: true,
token: getToken(),
};
const formData = new FormData();
for (let key in datasTrue) {
formData.append(key, datasTrue[key]);
}
console.log(datasTrue);
fetch(window.CONFIG.API_ACTION_PATH + '/safe/pub/getApis', {
headers: {
Accept: 'application/json',
},
method: 'POST',
credentials: 'omit',
mode: 'cors',
body: formData,
})
.then((res) => {
return res.json();
})
.then((res) => {
console.log(res);
});
}
export function getTransformApi(apiUrl = '/DataObjApi/getFormDataPage') { // api 表示一站式接口后缀.
const t = getToken();
const openIsBinary = window.CONFIG?.IS_BINARY;
if (!t || t.length < 11 || !openIsBinary) { // 没有token 或者没有开启二进制加密 直接返回 不需要转换
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
resolve(false); resolve(apiUrl);
}); });
}else{ } else {
let storage = localStorage.getItem('oneStopTransformApi'); const storage = localStorage.getItem('oneStopTransformApi');
// if(storage && isJSON()){ if (storage && isJSON(storage)) {
// let d = JSON.parse(storage);
// } if (d && d[api]) {
return new Promise((resolve, reject) => {
resolve(d[apiUrl]);
});
} else {
return getApi(apiUrl);
}
} else {
return getApi(apiUrl);
}
} }
} }
export function setTransformApi(api = '', transformApi = '') { export function setTransformApi(api = '', transformApi = '') {
const data = get; const t = getToken();
} }
...@@ -6,48 +6,12 @@ import { getHeaders, isJSON } from '@/webPublic/zyd_public/utils/utils'; ...@@ -6,48 +6,12 @@ import { getHeaders, isJSON } from '@/webPublic/zyd_public/utils/utils';
import { deepCopy } from '@/webPublic/one_stop_public/utils/myutils'; import { deepCopy } from '@/webPublic/one_stop_public/utils/myutils';
import { countAllValues } from '@/webPublic/one_stop_public/Base16/SplitBase16Index'; import { countAllValues } from '@/webPublic/one_stop_public/Base16/SplitBase16Index';
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils'; import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
// import strToBinary from './strToBinary'; // 字符串转二进制 混淆代码 import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
// import binaryToStr from './binaryToStr'; // 二进制字符串转JSON字符串 混淆代码 import { strToBinary } from './strToBinary'; // 字符串转二进制 混淆代码
import { binaryToStr } from './binaryToStr'; // 二进制字符串转JSON字符串 混淆代码
const test = !!(getUrlInfo().test); const test = !!(getUrlInfo().test);
/**
* 字符串转二进制
* */
function strToBinary(str) {
let result = [];
let list = str.split('');
for (let i = 0; i < list.length; i++) {
if (i !== 0) {
result.push('_');
}
let item = list[i];
let binaryStr = item.charCodeAt()
.toString(2);
result.push(binaryStr);
}
let resultStr = result.join('');
resultStr = resultStr.replaceAll('0', '-').replaceAll('1', '.');
return resultStr;
}
/**
* 二进制字符串转JSON字符串
* */
function binaryToStr(binaryStr = '') {
let res = '';
if (binaryStr) {
binaryStr = binaryStr.replaceAll('.', '1');
binaryStr = binaryStr.replaceAll('-', '0');
let strListArr = binaryStr.split('_');
for (let i = 0; i < strListArr.length; i++) {
let item = strListArr[i];
res += String.fromCharCode(parseInt(item, 2));
}
}
return res;
}
function formatDatas(datas, url = '') { function formatDatas(datas, url = '') {
let datasCode = JSON.stringify(datas); let datasCode = JSON.stringify(datas);
...@@ -138,7 +102,10 @@ export async function requestFileInfo(url, datas) { ...@@ -138,7 +102,10 @@ export async function requestFileInfo(url, datas) {
if (!url || typeof url !== 'string') { if (!url || typeof url !== 'string') {
return false; return false;
} }
return fetch(url && url.indexOf('http') > -1 ? url : queryApiActionPath() + url, {
const trueUrl = url && url.indexOf('http') > -1 ? url : queryApiActionPath() + url;
getTransformApi();
return fetch(trueUrl, {
headers: { headers: {
Accept: 'application/json', Accept: 'application/json',
...getHeaders(url).headers, ...getHeaders(url).headers,
......
// function _0x1fe1(_0xba4fa3, _0x1a5a2c) { /**
// const _0x210c64 = _0x210c(); * 二进制字符串转JSON字符串
// return _0x1fe1 = function (_0x1fe114, _0x38607b) { * */
// _0x1fe114 = _0x1fe114 - 0x124; export function binaryToStr(binaryStr = '') {
// let _0x638273 = _0x210c64[_0x1fe114]; let res = '';
// return _0x638273; if (binaryStr) {
// }, _0x1fe1(_0xba4fa3, _0x1a5a2c); binaryStr = binaryStr.replaceAll('.', '1');
// } binaryStr = binaryStr.replaceAll('-', '0');
// let strListArr = binaryStr.split('_');
// (function (_0x10c1af, _0x545339) {
// const _0x15b905 = _0x1fe1, for (let i = 0; i < strListArr.length; i++) {
// _0x316d2d = _0x10c1af(); let item = strListArr[i];
// while (!![]) { res += String.fromCharCode(parseInt(item, 2));
// try { }
// const _0x4e1d7b = -parseInt(_0x15b905(0x124)) / 0x1 + parseInt(_0x15b905(0x130)) / 0x2 + -parseInt(_0x15b905(0x12d)) / 0x3 * (parseInt(_0x15b905(0x12a)) / 0x4) + parseInt(_0x15b905(0x129)) / 0x5 * (parseInt(_0x15b905(0x128)) / 0x6) + parseInt(_0x15b905(0x12c)) / 0x7 * (parseInt(_0x15b905(0x127)) / 0x8) + -parseInt(_0x15b905(0x12f)) / 0x9 + parseInt(_0x15b905(0x12e)) / 0xa; }
// if (_0x4e1d7b === _0x545339) break; else _0x316d2d['push'](_0x316d2d['shift']()); return res;
// } catch (_0x4e17c4) { }
// _0x316d2d['push'](_0x316d2d['shift']());
// }
// }
// }(_0x210c, 0x4c89e));
//
// function _0x210c() {
// const _0xfdf36a = ['661315fARfsd', '4jTsGbX', 'split', '1154489jkyGqU', '1324143bPLxEM', '5021250iOAfBC', '4420215EKifMX', '537926uMCSQX', '86786XkjbYv', 'length', 'replaceAll', '8hyNtuX', '18ElZScC'];
// _0x210c = function () {
// return _0xfdf36a;
// };
// return _0x210c();
// }
//
// function binaryToStr(_0x3965d2 = '') {
// const _0xe2d440 = _0x1fe1;
// let _0x530667 = '';
// if (_0x3965d2) {
// _0x3965d2 = _0x3965d2[_0xe2d440(0x126)]('.', '1'), _0x3965d2 = _0x3965d2[_0xe2d440(0x126)]('-', '0');
// let _0xcdde8f = _0x3965d2[_0xe2d440(0x12b)]('_');
// for (let _0x6d2f3e = 0x0; _0x6d2f3e < _0xcdde8f[_0xe2d440(0x125)]; _0x6d2f3e++) {
// let _0x2c7a33 = _0xcdde8f[_0x6d2f3e];
// _0x530667 += String['fromCharCode'](parseInt(_0x2c7a33, 0x2));
// }
// }
// return _0x530667;
// }
// export default binaryToStr;
...@@ -6,6 +6,9 @@ const encryptApiList = [ ...@@ -6,6 +6,9 @@ const encryptApiList = [
{ {
api: 'UnifiedServicePatternApi/updateForm', api: 'UnifiedServicePatternApi/updateForm',
}, },
{
api: 'getApis',
},
{ {
api: 'UnifiedServicePatternApi/getDetail', api: 'UnifiedServicePatternApi/getDetail',
}, },
...@@ -144,7 +147,10 @@ const resBinaryApiList = [ ...@@ -144,7 +147,10 @@ const resBinaryApiList = [
{ {
api: 'SqlManageEntityApi/find', api: 'SqlManageEntityApi/find',
}, },
] {
api: 'getApis',
},
];
export { resBinaryApiList }; export { resBinaryApiList };
......
// /** /**
// * 代码混淆 * 字符串转二进制
// * 2022年6月21日 * */
// * 钟是志 export function strToBinary(str) {
// * 解决北电科学校的 第三方安全测评公司的问题 let result = [];
// * */ let list = str.split('');
// function _0x4ef8() { for (let i = 0; i < list.length; i++) {
// const _0x17bb5a = ['481374jxbvau', 'push', '28wsNjbv', '5xIHGnt', 'charCodeAt', '1024904tHoNdW', '11191763OpoFLZ', '624243CCgrxw', '2isqBwU', '1394360vTUesG', '387gETRxx', '96020VVIGLY', '367205YUbBcj']; if (i !== 0) {
// _0x4ef8 = function () { result.push('_');
// return _0x17bb5a; }
// }; let item = list[i];
// return _0x4ef8(); let binaryStr = item.charCodeAt()
// } .toString(2);
// result.push(binaryStr);
// function _0x251b(_0x3e6559, _0x18d143) { }
// const _0x4ef8c2 = _0x4ef8(); let resultStr = result.join('');
// return _0x251b = function (_0x251bf7, _0x3cfc29) { resultStr = resultStr.replaceAll('0', '-').replaceAll('1', '.');
// _0x251bf7 = _0x251bf7 - 0x10f; return resultStr;
// let _0x450bfc = _0x4ef8c2[_0x251bf7]; }
// return _0x450bfc;
// }, _0x251b(_0x3e6559, _0x18d143);
// }
//
// (function (_0xca7f49, _0x4d2eee) {
// const _0x1de042 = _0x251b,
// _0x4adbdc = _0xca7f49();
// while (!![]) {
// try {
// const _0x553796 = parseInt(_0x1de042(0x11b)) / 0x1 + parseInt(_0x1de042(0x117)) / 0x2 * (parseInt(_0x1de042(0x116)) / 0x3) + -parseInt(_0x1de042(0x114)) / 0x4 * (parseInt(_0x1de042(0x112)) / 0x5) + parseInt(_0x1de042(0x10f)) / 0x6 * (parseInt(_0x1de042(0x111)) / 0x7) + parseInt(_0x1de042(0x118)) / 0x8 + parseInt(_0x1de042(0x119)) / 0x9 * (parseInt(_0x1de042(0x11a)) / 0xa) + -parseInt(_0x1de042(0x115)) / 0xb;
// if (_0x553796 === _0x4d2eee) break; else _0x4adbdc['push'](_0x4adbdc['shift']());
// } catch (_0x44d7aa) {
// _0x4adbdc['push'](_0x4adbdc['shift']());
// }
// }
// }(_0x4ef8, 0x3333c));
//
// function strToBinary(_0x18b19e) {
// const _0x34cebd = _0x251b;
// let _0x54a5d7 = [],
// _0x4f6eaa = _0x18b19e['split']('');
// for (let _0x2bcf5e = 0x0; _0x2bcf5e < _0x4f6eaa['length']; _0x2bcf5e++) {
// _0x2bcf5e !== 0x0 && _0x54a5d7[_0x34cebd(0x110)]('_');
// let _0x435a20 = _0x4f6eaa[_0x2bcf5e],
// _0x1d8e9b = _0x435a20[_0x34cebd(0x113)]()['toString'](0x2);
// _0x54a5d7[_0x34cebd(0x110)](_0x1d8e9b);
// }
// let _0x3be325 = _0x54a5d7['join']('');
// return _0x3be325 = _0x3be325['replaceAll']('0', '-')['replaceAll']('1', '.'), _0x3be325;
// }
//
// export default strToBinary;
...@@ -19,6 +19,7 @@ import objectToFormData from '@/webPublic/zyd_public/utils/object-to-formdata-cu ...@@ -19,6 +19,7 @@ import objectToFormData from '@/webPublic/zyd_public/utils/object-to-formdata-cu
import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils'; import { getUrlInfo } from '@/webPublic/one_stop_public/DetailForAudit/utils';
import { getHeaders } from '@/webPublic/zyd_public/utils/utils'; import { getHeaders } from '@/webPublic/zyd_public/utils/utils';
import { proxyChangeUrl } from '@/webPublic/zyd_public/request/proxyChangeUrl'; import { proxyChangeUrl } from '@/webPublic/zyd_public/request/proxyChangeUrl';
import { getTransformApi } from '@/webPublic/one_stop_public/2022beidianke/localstorageTransform';
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: '服务器成功返回请求的数据。',
...@@ -135,6 +136,7 @@ export const request = (url, data, options = {}) => { ...@@ -135,6 +136,7 @@ export const request = (url, data, options = {}) => {
return giveBase16EnCode(data, url) return giveBase16EnCode(data, url)
.then((newData) => { .then((newData) => {
if (typeof newData === 'object' && newData.url && newData.datas) { if (typeof newData === 'object' && newData.url && newData.datas) {
console.log(newData);
return requestFileInfo(newData.url, newData.datas); return requestFileInfo(newData.url, newData.datas);
} }
return requestOrigin(url, newData, options); return requestOrigin(url, newData, options);
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import { isJSON } from '@/webPublic/one_stop_public/copy'; import { isJSON } from '@/webPublic/one_stop_public/copy';
import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils'; import { getOneStopMyInfo } from '@/webPublic/one_stop_public/utils/utils';
import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie'; import { delCookie, setCookie } from '@/webPublic/one_stop_public/utils/cookie';
import { getToken } from './getToken';
export { getToken } from './getToken'; export { getToken } from './getToken';
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论