Creating your own Tinyurl style uid

前端 未结 8 1967
抹茶落季
抹茶落季 2020-12-02 11:30

I\'m writing a small article on humanly readable alternatives to Guids/UIDs, for example those used on TinyURL for the url hashes (which are often printed in magazines, so n

8条回答
  •  北海茫月
    2020-12-02 12:14

    Why not just use a hashing algorithm? and use a hash of the url?

    if you are using random numbers chances are you will get clashes because they are indeterminate.

    hashes arent proovably unique but there is a fairly good chance that the hash of a string will be unique.

    Correction

    Actually wait you want them to be humanly readable... if you put them in hex they are technically humanly readable.

    or you could use an algorithm that converted a hash into a humanly readable string. if the humanly readable string is a different representation of the hash it should also be as "unique" as the hash, ie base 36 of the original hash.

提交回复
热议问题