简单的字符串散列函数 [英] Simple string hashing function

查看:98
本文介绍了简单的字符串散列函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一个字符串散列成一个整数,将其放在一个数组中。然而,我不太了解哈希函数,这就是为什么我当前的方法只是将所有ASCII字符加在一起,并将其改为数组大小。

I'm trying to hash a string into an integer for placing it in an array. However I do not know all too much about hashing functions, and that's why my current method is just adding all the ASCII numbers of the characters together and taking it mod the array size.

有没有简单的更快/更好的方法?

Are there any simple faster/better methods?

推荐答案

FNV-1a哈希很容易实现。

这篇关于简单的字符串散列函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆