我试图了解沙族中的填充。
填充邮件abc
为61626380000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000018
a=61
,b=62
和c=63
我明白了。 18
表示24 in hex
abc => 3.8
什么是8和整个零?
感谢您的回答
答案 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位内结束,则填充需要包含一个额外的块。