为什么hex-edit不可逆?

meA*_*bab 3 linux vi hex-editors

我有两个相同的.fit图像.

Linux @ Linux:〜/ imgs/ImageTesting#sha256sum hexd_ss.fit ss.fit

dff6b019b590edb3e9c61c984205c5f49a4064be34feb6207c88dc920aad17e0 hexd_ss.fit dff6b019b590edb3e9c61c984205c5f49a4064be34feb6207c88dc920aad17e0 ss.fit

我改变了一点hexd_ss.fit

Linux @ Linux:〜/ imgs/ImageTesting #vi hexd_ss.fit

0000 0000
Run Code Online (Sandbox Code Playgroud)

0000 0001
Run Code Online (Sandbox Code Playgroud)

所以我有两个不同的文件大小和不同的哈希

> Linux@Linux:~/imgs/ImageTesting# ls -l total 9344
> -rw-r--r-- 1 root root 4781261 Jun 16 15:45 hexd_ss.fit
> -rw-r--r-- 1 root root 4781260 Jun 16 15:33 ss.fit
> 
Run Code Online (Sandbox Code Playgroud)

Linux @ Linux:〜/ imgs/ImageTesting#sha256sum hexd_ss.fit ss.fit

f3277110043b4170c111fa7d4291aa7df23de68c9e504259ae6158e5133faf1a hexd_ss.fit dff6b019b590edb3e9c61c984205c5f49a4064be34feb6207c88dc920aad17e0 ss.fit

但是当我像以前一样再次改变那个位0时,它的大小和两个不同的哈希值保持不变.

改变之后

> 0000 0001  to > 0000 0000

Linux@Linux:~/imgs/ImageTesting# ls -l

-rw-r--r-- 1 root root 4781261 Jun 16 15:47 hexd_ss.fit
-rw-r--r-- 1 root root 4781260 Jun 16 15:33 ss.fit
Run Code Online (Sandbox Code Playgroud)

即使我将两个零字节更改为两个一个字节,大小也保持不变.如,

0000 1111

Linux@Linux:~/imgs/ImageTesting# ls -l

-rw-r--r-- 1 root root 4781261 Jun 16 15:47 hexd_ss.fit
-rw-r--r-- 1 root root 4781260 Jun 16 15:33 ss.fit
Run Code Online (Sandbox Code Playgroud)

所以我的问题是 -

  1. 为什么不能反转HexEdit?
  2. 如何或以其他方式将编辑反转到原点?

Arj*_*jan 5

我打开我的python3.5二进制用vi python3.5,然后做:%!xxd,:%!xxd -r,:wq...,结束了一个文件,该文件是1个字节大.请注意我甚至没有编辑任何东西.你应该使用

vi -b <file>
Run Code Online (Sandbox Code Playgroud)

vi... 打开二进制文件或打开它们时它们会被转换:P

我的python3.5二进制文件0a附加了一个- 换行符.删除此字节后,该文件与原始文件完全相同.