[英]How is the hash of a block in a bitcoin blockchain is 512 bits in size?
How does hash of a block in a bitcoin blockchain is 512 bits in size given that it is encoded using SHA-256 algorithm that should have a 256 bits output?比特币区块链中一个块的 hash 大小如何是 512 位,因为它是使用 SHA-256 算法编码的,应该有 256 位 output?
You're likely treating the hash as a string and calculating the bits for the string.您可能将 hash 视为字符串并计算字符串的位。
A hex string takes up 2x the space as the same information represented in bytes.一个十六进制字符串占用的空间是字节表示的相同信息的 2 倍。 For instance, if a hash were
00
, the bitcoin protocol would treat it as a single byte, 0x00
.例如,如果 hash 为
00
,比特币协议会将其视为单个字节0x00
。
Many other representations, however, would treat is as the string "00"
, which translates to 0x3030, or two bytes.然而,许多其他表示会将 is 视为字符串
"00"
,它转换为 0x3030 或两个字节。
If you have a 32 byte block hash in some program as a string, and you calculate the number of bits, you'll end up with 512 instead of 256.如果您在某些程序中有一个 32 字节块 hash 作为字符串,并且您计算位数,您最终会得到 512 而不是 256。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.