String to unique integer hashing

前端 未结 7 1374
日久生厌
日久生厌 2020-12-18 18:49

I\'m trying to develop a system that can change my string into a unique integral value, meaning say for example the word \"account\" has an encrypted numerical value of 0891

7条回答
  •  轮回少年
    2020-12-18 19:01

    Yes, but mostly no.

    Yes as in Stochastically's answer. By setting up a base 26 (or base 128 for all ASCII), you could theoretically hash each string uniquely.

    On the other hand, this is impractical, not only would numbers get too big for most languages, but also this would likely be an incredibly consuming process. Furthermore, if strings are allowed to be infinite, then a form of Cantor's diagonal argument can be applied also "breaking" this algorithm. It is impossible to create a one-to-one mapping of a set with cardinality aleph-one (strings) to a set of cardinality aleph-null (ints).

提交回复
热议问题