Skip to content

Commit

Permalink
(Enhance: Core/CMDLINUX) 内置hex解码器增加python3
Browse files Browse the repository at this point in the history
  • Loading branch information
Medicean committed Jul 25, 2021
1 parent 71fce91 commit a2e22e7
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/core/cmdlinux/decoder/hex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a2e22e7

Please sign in to comment.