Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
H
H5Public
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
CI / CD
CI / CD
流水线
作业
日程
统计图
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
H5Public
Commits
18ded40e
提交
18ded40e
authored
3月 10, 2022
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
接口需要加密
上级
5050d09c
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
294 行增加
和
0 行删除
+294
-0
basx-x.js
utils/Base16/basx-x.js
+123
-0
index.jsx
utils/Base16/index.jsx
+171
-0
没有找到文件。
utils/Base16/basx-x.js
0 → 100644
浏览文件 @
18ded40e
'use strict'
// base-x encoding / decoding
// Copyright (c) 2018 base-x contributors
// Copyright (c) 2014-2018 The Bitcoin Core developers (base58.cpp)
// Distributed under the MIT software license, see the accompanying
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
// @ts-ignore
var
_Buffer
=
require
(
'safe-buffer'
).
Buffer
function
base
(
ALPHABET
)
{
if
(
ALPHABET
.
length
>=
255
)
{
throw
new
TypeError
(
'Alphabet too long'
)
}
var
BASE_MAP
=
new
Uint8Array
(
256
)
for
(
var
j
=
0
;
j
<
BASE_MAP
.
length
;
j
++
)
{
BASE_MAP
[
j
]
=
255
}
for
(
var
i
=
0
;
i
<
ALPHABET
.
length
;
i
++
)
{
var
x
=
ALPHABET
.
charAt
(
i
)
var
xc
=
x
.
charCodeAt
(
0
)
if
(
BASE_MAP
[
xc
]
!==
255
)
{
throw
new
TypeError
(
x
+
' is ambiguous'
)
}
BASE_MAP
[
xc
]
=
i
}
var
BASE
=
ALPHABET
.
length
var
LEADER
=
ALPHABET
.
charAt
(
0
)
var
FACTOR
=
Math
.
log
(
BASE
)
/
Math
.
log
(
256
)
// log(BASE) / log(256), rounded up
var
iFACTOR
=
Math
.
log
(
256
)
/
Math
.
log
(
BASE
)
// log(256) / log(BASE), rounded up
function
encode
(
source
)
{
if
(
Array
.
isArray
(
source
)
||
source
instanceof
Uint8Array
)
{
source
=
_Buffer
.
from
(
source
)
}
if
(
!
_Buffer
.
isBuffer
(
source
))
{
throw
new
TypeError
(
'Expected Buffer'
)
}
if
(
source
.
length
===
0
)
{
return
''
}
// Skip & count leading zeroes.
var
zeroes
=
0
var
length
=
0
var
pbegin
=
0
var
pend
=
source
.
length
while
(
pbegin
!==
pend
&&
source
[
pbegin
]
===
0
)
{
pbegin
++
zeroes
++
}
// Allocate enough space in big-endian base58 representation.
var
size
=
((
pend
-
pbegin
)
*
iFACTOR
+
1
)
>>>
0
var
b58
=
new
Uint8Array
(
size
)
// Process the bytes.
while
(
pbegin
!==
pend
)
{
var
carry
=
source
[
pbegin
]
// Apply "b58 = b58 * 256 + ch".
var
i
=
0
for
(
var
it1
=
size
-
1
;
(
carry
!==
0
||
i
<
length
)
&&
(
it1
!==
-
1
);
it1
--
,
i
++
)
{
carry
+=
(
256
*
b58
[
it1
])
>>>
0
b58
[
it1
]
=
(
carry
%
BASE
)
>>>
0
carry
=
(
carry
/
BASE
)
>>>
0
}
if
(
carry
!==
0
)
{
throw
new
Error
(
'Non-zero carry'
)
}
length
=
i
pbegin
++
}
// Skip leading zeroes in base58 result.
var
it2
=
size
-
length
while
(
it2
!==
size
&&
b58
[
it2
]
===
0
)
{
it2
++
}
// Translate the result into a string.
var
str
=
LEADER
.
repeat
(
zeroes
)
for
(;
it2
<
size
;
++
it2
)
{
str
+=
ALPHABET
.
charAt
(
b58
[
it2
])
}
return
str
}
function
decodeUnsafe
(
source
)
{
if
(
typeof
source
!==
'string'
)
{
throw
new
TypeError
(
'Expected String'
)
}
if
(
source
.
length
===
0
)
{
return
_Buffer
.
alloc
(
0
)
}
var
psz
=
0
// Skip leading spaces.
if
(
source
[
psz
]
===
' '
)
{
return
}
// Skip and count leading '1's.
var
zeroes
=
0
var
length
=
0
while
(
source
[
psz
]
===
LEADER
)
{
zeroes
++
psz
++
}
// Allocate enough space in big-endian base256 representation.
var
size
=
(((
source
.
length
-
psz
)
*
FACTOR
)
+
1
)
>>>
0
// log(58) / log(256), rounded up.
var
b256
=
new
Uint8Array
(
size
)
// Process the characters.
while
(
source
[
psz
])
{
// Decode character
var
carry
=
BASE_MAP
[
source
.
charCodeAt
(
psz
)]
// Invalid character
if
(
carry
===
255
)
{
return
}
var
i
=
0
for
(
var
it3
=
size
-
1
;
(
carry
!==
0
||
i
<
length
)
&&
(
it3
!==
-
1
);
it3
--
,
i
++
)
{
carry
+=
(
BASE
*
b256
[
it3
])
>>>
0
b256
[
it3
]
=
(
carry
%
256
)
>>>
0
carry
=
(
carry
/
256
)
>>>
0
}
if
(
carry
!==
0
)
{
throw
new
Error
(
'Non-zero carry'
)
}
length
=
i
psz
++
}
// Skip trailing spaces.
if
(
source
[
psz
]
===
' '
)
{
return
}
// Skip leading zeroes in b256.
var
it4
=
size
-
length
while
(
it4
!==
size
&&
b256
[
it4
]
===
0
)
{
it4
++
}
var
vch
=
_Buffer
.
allocUnsafe
(
zeroes
+
(
size
-
it4
))
vch
.
fill
(
0x00
,
0
,
zeroes
)
var
j
=
zeroes
while
(
it4
!==
size
)
{
vch
[
j
++
]
=
b256
[
it4
++
]
}
return
vch
}
function
decode
(
string
)
{
var
buffer
=
decodeUnsafe
(
string
)
if
(
buffer
)
{
return
buffer
}
throw
new
Error
(
'Non-base'
+
BASE
+
' character'
)
}
return
{
encode
:
encode
,
decodeUnsafe
:
decodeUnsafe
,
decode
:
decode
}
}
module
.
exports
=
base
utils/Base16/index.jsx
0 → 100644
浏览文件 @
18ded40e
const
baseX
=
require
(
'./basx-x'
);
import
{
getOneStopData
as
apiRequest
}
from
'../../../pages/CollegeYongthLeague/services/activityDeclare'
;
import
{
isJSON
}
from
'../../../pages/utils/authority'
;
var
BASE16
=
'0123456789abcdef'
;
var
bs16
=
baseX
(
BASE16
);
function
checkOpenBase16
()
{
const
is_open_base14
=
sessionStorage
.
getItem
(
'is_open_base16'
)
?
JSON
.
parse
(
sessionStorage
.
getItem
(
'is_open_base16'
))
:
false
;
return
is_open_base14
;
}
export
function
Base16Encode
(
value
)
{
const
is_open_base14
=
checkOpenBase16
();
if
(
is_open_base14
)
{
if
(
!
value
)
{
return
null
;
}
else
{
let
newV
=
new
Buffer
(
value
);
// 快
const
r
=
bs16
.
encode
(
newV
);
// 慢
return
r
;
}
}
return
value
;
}
const
giveKey
=
(
key
,
datas
)
=>
{
if
(
datas
&&
datas
[
key
])
{
datas
[
key
]
=
Base16Encode
(
datas
[
key
]);
}
return
datas
;
};
const
encryptApiList
=
[
{
api
:
'DataColumnApi/getOptions'
,
key
:
[
'filterSql'
],
},
{
api
:
'DataColumnApi/getLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
setNull
:
true
,
},
{
api
:
'DataColumnApi/getSqlOptions'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlLabels'
,
key
:
[
'allValues'
],
filterEmpty
:
[
'allValues'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlData'
,
key
:
[
'allValues'
,
'sqlKey'
],
filterEmpty
:
[
'sqlKey'
],
query
:
true
,
},
{
api
:
'DataColumnApi/getSqlColumn'
,
key
:
[
'json'
],
},
{
api
:
'DataRightApi/add'
,
key
:
[
'filterSql'
],
// filterEmpty: ['filterSql'],
},
{
api
:
'DataRightApi/addBatch'
,
key
:
[
'filterSql'
],
},
{
api
:
'DataObjApi/add'
,
key
:
[
'sqlScript'
],
},
{
api
:
'DataObjApi/getFormDataList'
,
key
:
[
'custom'
],
},
{
api
:
'DataObjApi/getFormDataPage'
,
key
:
[
'sql'
,
'custom'
],
filterEmpty
:
[
'sql'
,
'custom'
],
},
{
api
:
'UserApi/getPage'
,
key
:
[
'addSignSql'
],
},
{
api
:
'UnifiedAppFormApi/examineProcess'
,
key
:
[
'taskForm'
],
},
{
api
:
'UnifiedAppFormApi/saveDraft'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcess'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/startProcessByService'
,
key
:
[
'content'
],
},
{
api
:
'UnifiedAppFormApi/getHandleUser'
,
key
:
[
'content'
],
},
{
api
:
'SqlManageEntityApi/findParamsKey'
,
key
:
[
'sqlKey'
],
},
];
const
countAllValues
=
async
(
datas
,
item
)
=>
{
if
(
item
.
setNull
)
{
datas
.
allValues
=
JSON
.
stringify
({});
}
else
{
if
(
item
.
query
)
{
if
(
datas
?.
sqlKey
.
length
<
13
)
{
const
response
=
await
apiRequest
(
'/SqlManageEntityApi/findParamsKey'
,
{
sqlKey
:
datas
.
sqlKey
});
if
(
!
response
||
(
Array
.
isArray
(
response
)
&&
response
.
length
===
0
))
{
datas
.
allValues
=
JSON
.
stringify
({});
}
else
{
const
x
=
isJSON
(
datas
.
allValues
)
&&
JSON
.
parse
(
datas
.
allValues
)
||
{};
const
y
=
{};
for
(
let
i
of
response
)
{
if
(
x
[
i
])
{
y
[
i
]
=
x
[
i
];
}
datas
.
allValues
=
JSON
.
stringify
(
y
);
}
}
}
else
{
datas
.
allValues
=
JSON
.
stringify
({});
}
}
}
return
datas
;
};
export
async
function
giveBase16EnCode
(
datas
,
url
)
{
// 全局加解密函数.
if
(
!
checkOpenBase16
())
{
return
datas
;
}
if
(
url
&&
typeof
url
===
'string'
)
{
for
(
let
item
of
encryptApiList
)
{
if
(
url
.
indexOf
(
item
.
api
)
>
-
1
)
{
for
(
let
g
of
item
.
key
)
{
if
(
g
===
'allValues'
&&
typeof
datas
[
g
]
!==
'undefined'
)
{
datas
=
await
countAllValues
(
datas
,
item
);
// 循环中 不要写await
datas
=
giveKey
(
'allValues'
,
datas
);
}
else
{
datas
=
giveKey
(
g
,
datas
);
}
}
return
datas
;
}
}
}
return
datas
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论