emn178 / online-tools

Online tools provides md2, md5, sha1, sha2, sha512, bas64, html encode / decode functions
791 stars 356 forks source link

Pad10*1 of input #30

Closed anhtai090601 closed 1 year ago

anhtai090601 commented 1 year ago

when i use SHA3-224 to calculate 2 input hexadecimal: 00112233445566778899AABBCCDDEEFF and 00112233445566778899AABBCCDDEEFF0. I have 2 different results. Can anyone tell me how the input was processed before implementation?

emn178 commented 1 year ago

Hex will convert to bytes first. If the length is not multiples of two, it will prepend 0. For example, FF0 will be the same with 0FF0

anhtai090601 commented 1 year ago

Hex will convert to bytes first. If the length is not multiples of two, it will prepend 0. For example, FF0 will be the same with 0FF0 Can you explain in more detail? I still do not understand.

emn178 commented 1 year ago

FF is one byte [255] FF0 is two bytes [15, 240]. It is 0FF0 not FF00.

In your case: 00112233445566778899AABBCCDDEEFF is [0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255] 00112233445566778899AABBCCDDEEFF0 is [0, 1, 18, 35, 52, 69, 86, 103, 120, 137, 154, 171, 188, 205, 222, 239, 240]

anhtai090601 commented 1 year ago

Okay thanks you, Now i'm understand