The sha1 hash for 64test64xa is 6779c53432b8badf049bb9d8924a5785dd887243 which is 41 characters only using hexadecimal, 10digits and 6letters. But how long it would be if it was using the whole 26 letters in the latin alphabet? What if it also differentiated between UPPER and lower cases?

  • mozz@mbin.grits.dev
    link
    fedilink
    arrow-up
    9
    ·
    edit-2
    11 months ago
    1. It’s a 160-bit hash, so using letters and numbers, it’d be log base (10+26) of 2^160, which is roughly 31. So 31 letters.
    2. Using upper and lower case, it’d be log base (10+26+26) of 2^160, or 27 letters.
    3. Don’t use SHA-1; use SHA-256
    4. Upper and lower case to represent SHA-256 would be log base (10+26+26) of 2^256, 43 letters
    5. Internally, it’s represented using 32 “letters” of 8 bits each, effectively using every possible ASCII character. The string representation is only of consequence when you’re exchanging it over a medium where it needs to be robust and human-readable, and probably the benefit from squeezing it down to fewer characters for that representation is not worth the cost in terms of making it unclear how you’ve chosen to squeeze it and making life difficult for people who are trying to convert to and from the format. Hexadecimal is a little bigger but it’s very clear and unambiguous what you’ve done, whereas using the full alphabet doesn’t have that property.