哈希函数的设计 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
请不要在回答技术问题时复制粘贴 AI 生成的内容
allAboutDbmss

哈希函数的设计

  •  
  •   allAboutDbmss 2022 年 5 月 3 日 1556 次点击
    这是一个创建于 1452 天前的主题,其中的信息可能已经有所发展或是发生改变。

    记得上次看到有哈希表的设计,我觉得那个比较困难。 这里分享一个别人的哈希函数 hash function 的设计文章,读起来大概十五分钟:

    https://nullprogram.com/blog/2018/07/31/ https://github.com/skeeto/hash-prospector

    Takeaway:

    • 几个现成的哈希函数

    • 如果哈希函数是 1:1 (reversible) 那么是没有哈希冲突的

    My focus is on integer hash functions: a function that accepts an n-bit integer and returns an n-bit integer. One of the important properties of an integer hash function is that it maps its inputs to outputs 1:1. In other words, there are no collisions

    • 两个设计和评价哈希函数的角度: 公平和偏离

    There are two key properties I’m looking for in randomly generated hash functions. 1. High avalanche effect. When I flip one input bit, the output bits should each flip with a 50% chance. 2. Low bias. Ideally there is no correlation between which output bits flip for a particular flipped input bit.

    (我个人觉得这两点都是在说 bias)

    2 条回复    2022-05-03 17:45:51 +08:00
    documentzhangx66
        1
    documentzhangx66  
       2022 年 5 月 3 日
    上次那老哥说的是 Minimal_perfect_hash_function ,与 我们常见的 MD5 、SHA1 这类哈希,根本是不同的东西,只是名称中都包含了 HASH ,于是大家先入为主地,以为那位老哥在说 MD5 、SHA1 之类的主流哈希算法。那位老哥说的那种更像是根据 value 反推 ID key 的 index 查找算法。
    allAboutDbmss
        2
    allAboutDbmss  
    OP
       2022 年 5 月 3 日
    @documentzhangx66 是的
    我这个链接就是一个哈希表哈希函数 需要公平和高性能
    所以这个也不是 md5 甚至一些加密哈希算法
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     872 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 38ms UTC 21:18 PVG 05:18 LAX 14:18 JFK 17:18
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86