我刚刚跑过
$ sha1sum myfile
因为无聊。
myfile 是我用它创建的一个空文件
$ touch myfile
令我惊讶的是 sha1sum 实际上返回了一个校验和。这些校验和不是应该根据一些非空内容计算出来吗?空文件的校验和只是一个硬编码的“魔法”常量吗?
最佳答案
空消息与带有数据字节的消息没有什么本质上的不同。该算法描述如下 http://en.wikipedia.org/wiki/SHA-1#Examples_and_pseudocode零数据就可以了。
例如。
Pre-processing:
append the bit '1' to the message append 0 ≤ k < 512 bits '0', so that the resulting message length (in bits) is congruent to 448 (mod 512)
关于sha1 - 如何计算空文件的加密校验和?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11713258/