Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do the SHA1 of a string always return ASCII characters?

Tags:

sha1

The input string can be a unicode string.Do the output string after calculating SHA1 will always return ASCII characters?

like image 911
bhanu Avatar asked Jun 30 '11 02:06

bhanu


1 Answers

It depends but strictly speaking, no. The output of the SHA-1 hash is 160 bits, or 20 bytes, but the bytes are not guaranteed to be in the ASCII range.

However, some hash functions output the hex equivalent (i.e. 40 characters) of the 20 bytes, so if the first three bytes of the actual hash are 0x7e, 0x03, and 0xb2, the output would begin with "7e03b2", in which case the output is ASCII.

like image 107
Graeme Perrow Avatar answered Oct 10 '22 12:10

Graeme Perrow