Get unique integer value from string

前端 未结 5 1762
我在风中等你
我在风中等你 2021-02-07 06:34

I have different unique strings in the same format. The string looks like this axf25!j&809>-11~dc and I want to get unique integer value from this string.

5条回答
  •  北荒
    北荒 (楼主)
    2021-02-07 06:59

    You cannot generate entirely unique ints from sufficiently long strings because there are more 10-character strings than 32-bit integers.

    As far as non-unique solutions go, you can use the standard hashCode function, its implementation in Java is reasonably good. For more complex stuff you may consider computing cryptographic hash (SHA-2, MD5, etc.)

提交回复
热议问题