How to design a sequential hash-like function

后端 未结 6 451
谎友^
谎友^ 2020-12-14 04:57

I want to develop something similar to jsfiddle in where the user can input some data and then \"save\" it and get a unique random looking url that loads that data.

6条回答
  •  醉话见心
    2020-12-14 05:21

    This can't really be reversible. The only way (the one used by url shorteners and jsfiddle) is to store the generated hash (actually it's a digest) in a table/data structure of some sort and *look it up on retrieval.

    Why this?

    Passing from, e.g. 128 chars of data → a 4 visible char digest, you lose a lot of data.
    You cannot store the remaining data in the magical cracks betweeen those 4 bytes, there are none.

提交回复
热议问题