How to generate a unique hash code for string input in android…?

前端 未结 8 528
迷失自我
迷失自我 2020-12-13 03:41

I wanted to generate a unique hash code for a string in put in android. Is there any predefined library is there or we have to generate manually. Please any body if knows pl

8条回答
  •  旧时难觅i
    2020-12-13 04:18

    You can use this code for generating has code for a given string.

    int hash = 7;
    for (int i = 0; i < strlen; i++) {
        hash = hash*31 + charAt(i);
    }
    

提交回复
热议问题