Sorry for this curiosity that I have.
sha1 use [a-f0-9] chars for its hashing function. May I know why it doens’t use all the chars possible [a-z0-9] by using all chars availabe it could grealty increase the number of possibile different hash, thus lowering the probabilty of possibile collision.
If you don’t think this is a real question, just leave a comment I will instantly delete this question.
===
As stated in the answer, sha1 does NOT uses only 16 chars. The correct fact is: sha1 is 160 bits of binary data (cit.). I have added this to prevent confusion.
You’re confusing representation with content.
sha1 is 160 bits of binary data. You can just as easily represent it with:
There’s nothing magical about hexidecimal. It’s just very common mechanism for showing content that breaks easily along 4-bit boundaries.
The
base 62output is generated with this little bit of ruby:It uses the standard idiom for converting from one base to another and treats
0-9as 0-9,a-zas 10-35,A-Zas 36-61. It could be trivially extended to support more digits by including e.g.!@#$%^&*()-_=+\|[]{},.<>/?;:'"~`if one so desired. (Or any of the vast array of Unicode codepoints.)@yes123 asked about the ascii representation of the hash specifically, so here is the result of interpreting the 160-bit hash directly as ascii:
It doesn’t look like much because:
This base conversion can be practically useful, too; the Base64 encoding method uses 64 (instead of my 62) characters to represent 6 bits at a time; it needs two more characters for ‘digits’ and a character for padding. UUEncoding chose a different set of ‘digits’. And a fellow stacker had a problem that was easily solved by changing the base of input numbers to output numbers.