本文介绍了什么是单个“1”的SHA-256散列?位?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SHA-256的定义似乎是这样的,即由单个1位组成的输入具有明确定义的散列值,与01字节不同填充是根据输入的长度以位为单位完成的)。

然而,由于字节顺序问题以及没有可以找到支持单个位的实现的事实,我无法完全弄清楚这个正确的值是什么。



那么, 1位long 输入的正确散列是什么?位1? (不是8位长字节[] {1}输入)。

解决方案

好的,根据我自己的实现:

1位字符串1

  B9DEBF7D 52F36E64 68A54817 C1FA0711 66C3A63D 384850E1 575B42F7 02DC5AA1 

1位字符串0 :

  BD4F9E98 BEB68C6E AD3243B1 B4C7FED7 5FA4FEAA B1F84795 CBD8A986 76A2A375 

我已经在几个标准8位多位输入(包括0位字符串)上测试了这个实现,结果是正确的。



(当然这个问题的关键在于首先验证上述输出,所以请谨慎使用......)

The definition of SHA-256 appears to be such that the input consisting of a single "1" bit has a well-defined hash value, distinct from that of the "01" byte (since the padding is done based on input's length in bits).

However, due to endianness issues and the fact that no implementations that I can find support feeding in single bits, I can't quite figure out what this correct value is.

So, what is the correct hash of the 1-bit long input consisting of the bit "1"? (not the 8-bit long byte[] { 1 } input).

解决方案

OK, according to my own implementation:

1-bit string "1":

B9DEBF7D 52F36E64 68A54817 C1FA0711 66C3A63D 384850E1 575B42F7 02DC5AA1

1-bit string "0":

BD4F9E98 BEB68C6E AD3243B1 B4C7FED7 5FA4FEAA B1F84795 CBD8A986 76A2A375

I have tested this implementation on several standard multiples-of-8-bits inputs, including the 0-bit string, and the results were correct.

(of course the point of this question was to validate the above outputs in the first place, so use with care...)

这篇关于什么是单个“1”的SHA-256散列?位?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 09:29