如何将 java 中的字符串转换为数字?但我不是在寻找 hashCode,因为它不会提供唯一编号。至少我想要相同的数学逻辑

How to convert string to number in java ? But i am not looking for hashCode as it wont give unique number. at least i want math logic for same

您好,我想将字符串转换为 java 中的某个唯一数字。 示例:"Production-0-1" 至 100021 "Process-23-30" 至 12310 并且所有 return 号码都必须是唯一的。 我不想使用 hashCode,因为它们可以 return 复制,就像 "Aa" 和 "BB" 有相同的代码。 让我知道创建这个的数学逻辑没有可用的方法。

    String random = "Production-0-1";
    String bi = new BigInteger(random.getBytes("UTF-8")).toString();
    BigInteger numBig = new BigInteger(bi);
    System.out.println(numBig);

根据@markspace 的评论,我尝试了以下方法,每次它都会生成随机的唯一数字,但要注意如果你有一个非常大的字符串和有限的内存 space 那么输出可能出界