代码之家  ›  专栏  ›  技术社区  ›  Vijay

PHP散列方法的区别是什么?

  •  1
  • Vijay  · 技术社区  · 14 年前

    What is the difference between the hashing methods available in php

    md2 md4 md5 sha1 sha224 sha256 sha384 sha512 ripemd128 ripemd160 ripemd256 
    ripemd320 whirlpool tiger128,3 tiger160,3 tiger192,3 tiger128,4 tiger160,
    4 tiger192,4 snefru snefru256 gost adler32 crc32 crc32b salsa10 salsa20 
    haval128,3 haval160,3 haval192,3 haval224,3 haval256,3 haval128,4 haval160,
    4 haval192,4 haval224,4 haval256,4 haval128,5 haval160,5 haval192,
    5 haval224,5 haval256
    

    I generally use md5 to store passwords in my db..

    我寻找它,但我不能得到确切的优点和缺点。

    3 回复  |  直到 14 年前
        1
  •  9
  •   Pete    14 年前

    不同之处在于所使用的算法,它也决定了输出的大小(例如,MD5产生128位输出,SHA 160位)。

    MD5和SHA1的弱点已经被发现(散列空间中的冲突),但对于大多数情况来说,MD5是足够的,除非您在银行网站上工作。

    但是,您必须使用salt(不管使用的哈希算法如何),例如,仅使用密码的md5就可能使您容易受到彩虹攻击。

        2
  •  14
  •   Michael Borgwardt    14 年前

    这些都是不同的算法。其中一些是加密散列,一些是简单的校验和(如crc32和adler32),计算速度非常快,但不应用于加密目的。

    MD5 and SHA-1 used to be the standard cryptographic hashes, but recently weaknesses have been found in both. 您最好使用新的sha-256进行加密。其他新的sha变体使用更少或更多的位,但没有根本不同。

    You can probably find more detailed information about most of those algorightms on Wikipedia.

        3
  •  3
  •   Arkh    14 年前

    You don't want to use md5 or any "simple" hash to store passwords in a database. 你想要一个 good salt bcrypt . 这个 phpass library provide a good portable way to implement a not too weak password storage.