您的位置:首页 > 编程语言 > C语言/C++

重新认识C语言

2015-07-05 13:54 429 查看
public class SSS {

public static void main(String[] args) {

String str = "@7LOBlHIXq";
int s = encrypt(str);
System.out.println(s);
System.out.println(1167191711);
}

// &g_tk=1167191711&r=0.08814051181907784

public static int encrypt(String g_tk) {

int hash = 5381;
for (int i = 0, len = g_tk.length(); i < len; ++i) {
char ch = g_tk.charAt(i);
int tmp = (int) ch;
String s = Integer.toHexString(tmp);
hash += (hash << 5) + Integer.parseInt(s, 16);

}
return hash & 0x7fffffff;

}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: