feat: 新增 eapi 解析接口和使用 demo

This commit is contained in:
binaryify
2024-05-07 15:17:56 +08:00
parent 1c1c850b51
commit 15a2e1bcdf
8 changed files with 182 additions and 15 deletions

26
module/eapi_decrypt.js Normal file
View File

@ -0,0 +1,26 @@
const { eapiResDecrypt, eapiReqDecrypt } = require('../util/crypto')
module.exports = async (query, request) => {
const hexString = query.hexString
const isFormat = query.isFormat != 'false'
if (!hexString) {
return {
status: 400,
body: {
code: 400,
message: 'hex string is required',
},
}
}
// 去除空格
let pureHexString = hexString.replace(/\s/g, '')
return {
status: 200,
body: {
code: 200,
data: isFormat
? eapiReqDecrypt(pureHexString)
: eapiResDecrypt(pureHexString),
},
}
}