From a2e22e7189bef70f4a7e02c678606e9700027c84 Mon Sep 17 00:00:00 2001 From: Medicean Date: Sun, 25 Jul 2021 11:49:02 +0800 Subject: [PATCH] =?UTF-8?q?(Enhance:=20Core/CMDLINUX)=20=E5=86=85=E7=BD=AE?= =?UTF-8?q?hex=E8=A7=A3=E7=A0=81=E5=99=A8=E5=A2=9E=E5=8A=A0python3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- source/core/cmdlinux/decoder/hex.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/core/cmdlinux/decoder/hex.js b/source/core/cmdlinux/decoder/hex.js index 47458acd..3cf71f90 100644 --- a/source/core/cmdlinux/decoder/hex.js +++ b/source/core/cmdlinux/decoder/hex.js @@ -9,7 +9,14 @@ * @returns {string} asenc 加密返回数据的函数 */ asoutput: () => { - return `asenc(){ xxd -ps "$@"; };` + return `asenc(){ + command_exists() { command -v "$@" > /dev/null 2>&1; }; + if command_exists xxd; then + xxd -ps "$@"; + elif command_exists python3; then + echo -n "$@"|python3 -c "import sys, binascii; sys.stdout.buffer.write(binascii.hexlify(input().strip().encode()))"; + fi + };`.replace(/\n\s+/g, '') }, /** * 解码 Buffer