简体   繁体   English

Base64编码修改仅可打印的字符

[英]Base64 encoded modifying just printable char

I have a base64 string that contains not printable chars. 我有一个base64字符串,其中包含不可打印的字符。

I want to modify just the printable one. 我只想修改可打印的内容。 But i can't use base64 -d because I will lost the not printable ones. 但是我不能使用base64 -d,因为我会丢失那些不可打印的。

Is that a command that allow me to do that? 那是我可以执行的命令吗?

Example, if I do 例如,如果我这样做

echo "base64 string" | base64 -d | od -c 

I obtain 我得到

0000000 004 002 254 334   0 202 003 362  \f  \0   0 202 003 354   0 202
0000020 003 350 002 002 006 021   0   -   0   )   0 036 002 004   A 343
0000040 271   | 002 003  \0 352 233 002 002 021 340 002 002  \0 232 002
0000060 001   . 004 006  \0  \f   ) 346 353 323  \f  \a   J   0   0   6
0000100   0   6

etc... 等等...

let's say I want to modify just the J 0 0 with J 0 1...I can do this? 假设我只想用J 0 1修改J 0 0 ...我可以这样做吗?

UPDATE: 更新:

For the moment the solution was in convert and output the base64 decode into a file and then edit it with an HEX Editor. 目前,解决方案是转换并将base64解码输出到文件中,然后使用HEX编辑器对其进行编辑。

So if you know some command line HEX Editor native included in linux please tell me 因此,如果您知道Linux中包含的某些命令行HEX Editor本机,请告诉我

When I try it on my system I get 当我在系统上尝试时,我得到

base64: invalid input base64:无效的输入

Since you want printable characters only, I'm suspecting that what you want is a base64 encoded string. 由于您只需要可打印的字符,因此我怀疑您想要的是base64编码的字符串。

If so, you should skipe the -d option: 如果是这样,则应跳过-d选项:

echo "base64 string" | base64 | od -c

If you really want to change some characters into others, you could use the tr (translate) command: 如果您确实想将某些字符更改为其他字符,则可以使用tr (翻译)命令:

From man tr : man tr

tr - translate or delete characters tr翻译或删除字符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM