如何执行基本64从CLI进行编码,而无需base64命令?

问题描述 投票:0回答:2
我在忙箱系统上,我无法安装任何软件包,并且不包括

base64

命令。但是,我需要运行一个使用
base64
/编码的脚本。还有另一种方法吗?也许在脚本中的功能?

bash base64 busybox
2个回答
2
投票
e.g。

openssl可以编码并解码base64

$ openssl enc -base64 <<< 'Hello, World!' SGVsbG8sIFdvcmxkIQo= $ openssl enc -base64 -d <<< SGVsbG8sIFdvcmxkIQo= Hello, World!

1980年以来,这已可以使用

Https://en.wikipedia.org/wiki/uuencoding

Busybox具有

0
投票
具有base64支持:

uuencode [-m] [infile] stored_filename Uuencode a file to stdout Options: -m Use base64 encoding per RFC1521 us示例:

$ echo 'foo' | uuencode -m - begin-base64 644 - Zm9vCg== ==== 使用其他工具确认它是正确的:

$ echo 'foo' | b64encode -
begin-base64 644 -
Zm9vCg==
====
$ echo 'foo' | openssl base64      
Zm9vCg==
$ echo 'foo' | python3 -c 'import base64; import fileinput; print(base64.b64encode("".join(fileinput.input(encoding="utf-8")).encode()))'
b'Zm9vCg=='

编码:

$ printf 'Zm9vCg==' | openssl base64 -d -A
foo
$ printf 'Zm9vCg==' | python3 -m base64 -d
foo

可以在Base Busybox上进行编码,例如,使用此尴尬脚本

https://superuser.com/a/1871180

    

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.