如何填写sha系列中的消息

时间:2014-08-28 11:15:12

标签: algorithm hash padding sha

我试图了解沙族中的填充。

填充邮件abc61626380000000000000000000000000000000000000000000000000000000000000000000000000 000000000000000000000000000000000000000000000018

a=61b=62c=63我明白了。 18表示24 in hex

abc => 3.8

什么是8和整个零?

感谢您的回答

1 个答案:

答案 0 :(得分:0)

扩展someWhereElse的评论。 SHA填充将消息扩展到下一个块边界。在消息的末尾添加一个1位(非字节),后跟零位,直到块结尾的64位。使用块的最后64位来保存消息的长度为二进制。

您的衬垫块由以下部分组成:

616263 : "abc" - the message text.
8      : "1000" - the 1 bit to start the padding, followed by padding zeros.
0...0  : The rest of the padding zero bits.
0000000000000018 : 64 bit message length, 24 bits in this case.

如果消息在块边界的65位内结束,则填充需要包含一个额外的块。