Hash algorithm with alphanumeric output of 20 characters max

后端 未结 1 1365
粉色の甜心
粉色の甜心 2021-02-19 16:02

I need an hash algorithm that outputs an alphanumeric string that is max 20 characters long. For \"alphanumeric\" I mean [a-zA-Z0-9].

Inputs are UUIDs in ca

1条回答
  •  醉梦人生
    2021-02-19 17:01

    Just clip the characters you don't need from the hash of the GUID. With a good hash function, the unpredictability of any part of the hash is proportional to the part's size. If you want, you can encode it base 32 instead of the standard hex base 16. Bear in mind that this will not significantly improve entropy per character (only by 25%).

    For non-cryptographic uses, it does not matter whether you truncate MD5, SHA1 or SHA2. Neither has any glaring deficiencies in entropy.

    0 讨论(0)
提交回复
热议问题