douti19680318 2013-05-05 06:54 采纳率: 0%
浏览 124
已采纳

可以将varchar(32)用于md5哈希

Just a simple question I am using varchar(50) NOT NULL, for md5 hash code

Just want to know if its ok to use it as 32?

Another thing i have millions of md5 hash code as far they dont match with other, is there a cash that two different keyword can have same md5 hash?

Thanks

  • 写回答

2条回答 默认 最新

  • doute7910 2013-05-05 08:21
    关注

    VARCHAR is for strings where you don't know the length, you trade off a lesser performance for a greater flexibility. As you know the field will be 32 characters long, you should use CHAR(32) (which expects exactly 32 characters) instead.

    As for collision possibility: yes, MD5 hashes can be identical. An easy way to test this for yourself is to md5sum a 33-character hexadecimal number. If this works, you know that there are more possible inputs than outputs, so two inputs must be able to map to the same output.

    These two blocks (courtesy of this link) famously both give an md5sum of 79054025255fb1a26e4bc422aef54eb4:

    BLOCK 1:
    d131dd02c5e6eec4693d9a0698aff95c 2fcab58712467eab4004583eb8fb7f89
    55ad340609f4b30283e488832571415a 085125e8f7cdc99fd91dbdf280373c5b
    d8823e3156348f5bae6dacd436c919c6 dd53e2b487da03fd02396306d248cda0
    e99f33420f577ee8ce54b67080a80d1e c69821bcb6a8839396f9652b6ff72a70
    
    BLOCK 2:
    d131dd02c5e6eec4693d9a0698aff95c 2fcab50712467eab4004583eb8fb7f89
    55ad340609f4b30283e4888325f1415a 085125e8f7cdc99fd91dbd7280373c5b
    d8823e3156348f5bae6dacd436c919c6 dd53e23487da03fd02396306d248cda0
    e99f33420f577ee8ce54b67080280d1e c69821bcb6a8839396f965ab6ff72a70
    

    This website provides a visualization into why those particular strings collide, if you're interested (it's quite technical but very interesting if you want to better understand message digest and hashing).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?