Why is a SHA-1 Hash 40 characters long if it is only 160 bit?

后端 未结 6 476
自闭症患者
自闭症患者 2020-12-23 10:00

The title of the question says it all. I have been researching SHA-1 and most places I see it being 40 Hex Characters long which to me is 640bit. Could it not be represented

6条回答
  •  自闭症患者
    2020-12-23 10:07

    One hex character can only represent 16 different values, i.e. 4 bits. (16 = 24)

    40 × 4 = 160.


    And no, you need much more than 5 characters in base-36.

    There are totally 2160 different SHA-1 hashes.

    2160 = 1640, so this is another reason why we need 40 hex digits.

    But 2160 = 36160 log362 = 3630.9482..., so you still need 31 characters using base-36.

提交回复
热议问题