使用 Linux 命令将十六进制信息转换为二进制 [英] Transform hexadecimal information to binary using a Linux command

查看:23
本文介绍了使用 Linux 命令将十六进制信息转换为二进制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 Linux 系统上有这个二进制文件...

I have this binary file on my Linux system...

 udit@udit-Dabba ~ $ cat file.enc
 Salted__s�bO��<0�F���Jw!���]�:`C�LKȆ�l

使用 hexdump 命令,我看到它的信息如下:

Using the hexdump command, I see its information like this:

 udit@udit-Dabba ~ $ hexdump -C file.enc
 00000000  53 61 6c 74 65 64 5f 5f  1b 73 a1 62 4f 15 be f6  |Salted__.s.bO...|
 00000010  3c 30 cc 46 ee 10 13 11  84 bf 4a 77 21 a4 84 99  |<0.F......Jw!...|
 00000020  0e 5d ef 11 18 3a 60 43  a0 4c 4b 1e c8 86 e6 6c  |.]...:`C.LK....l|
 00000030

现在我在其他系统上获得了一个文件,其内容如下:

Now I am given a file on some other system whose contents are like this:

 53 61 6c 74 65 64 5f 5f  1b 73 a1 62 4f 15 be f6
 3c 30 cc 46 ee 10 13 11  84 bf 4a 77 21 a4 84 99
 0e 5d ef 11 18 3a 60 43  a0 4c 4b 1e c8 86 e6 6c

我需要从这个 hexdump 中找出完全相同的二进制信息.

And I need to find out that same exact binary information from this hexdump.

我该怎么做?

如果没有任何开关,那么 C 代码也可以正常工作.

If there isn't any switch for that then C code will also work fine.

(但最好是带有一些开关的 Linux 命令)

(But a Linux command with some switch is preferable)

限制:

文件中的二进制信息是加密算法的输出,所以内容应该完全匹配...

The binary information in the file is output of an encryption algorithm, so contents should exactly match...

推荐答案

按照@user786653 的建议,使用 xxd(1) 程序:

As @user786653 suggested, use the xxd(1) program:

xxd -r -p input.txt output.bin

这篇关于使用 Linux 命令将十六进制信息转换为二进制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆