良好的校验和可加快搜索速度
我想通过创建字符串的校验和索引来加快应用程序的搜索速度。
CRC32 足够好吗?我使用它不是为了安全。就像将字符串表示为散列(整数/长整型)索引的方法一样。
I want to speed up the search of my application by creating an checksum index of my strings.
Is CRC32 good enough? I'm not using it for security. Just as a way to represent a string as a hashed(Integer/Long) index.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您正在寻找哈希码,而不是校验和。 CRC32 应该没问题,但效率不高。另请查看 Adler32(zlib 使用),它的计算速度更快。
另请参阅哈希函数
You're looking for a hash code, not a checksum. CRC32 should be fine though, but not very efficient. Also have a look at Adler32 (used by zlib), which is faster to calculate.
See also Hash function
您是否试图重新发明轮子,或者在本例中是哈希表?
CRC32 用于计算校验和,它并不是设计为快速哈希函数,而是设计用于检测文件中的错误(更改)。
四个您的需求,您可能更想查看非加密哈希函数。
Are you trying to reinvent the wheel, or in this case a hash table?
CRC32 is for calculating checksums, it's not designed to be fast hash function, it's designed to detect errors (changes) in files.
Four your needs, you might rather want to look at non-cryptographic hash functions.