Difference between Hashing a Password and Encrypting it

前端 未结 9 797
野的像风
野的像风 2020-11-22 02:46

The current top-voted to this question states:

Another one that\'s not so much a security issue, although it is security-related, is complete and abje

9条回答
  •  没有蜡笔的小新
    2020-11-22 03:08

    Hashing:

    It is a one-way algorithm and once hashed can not rollback and this is its sweet point against encryption.

    Encryption

    If we perform encryption, there will a key to do this. If this key will be leaked all of your passwords could be decrypted easily.

    On the other hand, even if your database will be hacked or your server admin took data from DB and you used hashed passwords, the hacker will not able to break these hashed passwords. This would actually practically impossible if we use hashing with proper salt and additional security with PBKDF2.

    If you want to take a look at how should you write your hash functions, you can visit here.

    There are many algorithms to perform hashing.

    1. MD5 - Uses the Message Digest Algorithm 5 (MD5) hash function. The output hash is 128 bits in length. The MD5 algorithm was designed by Ron Rivest in the early 1990s and is not a preferred option today.

    2. SHA1 - Uses Security Hash Algorithm (SHA1) hash published in 1995. The output hash is 160 bits in length. Although most widely used, this is not a preferred option today.

    3. HMACSHA256, HMACSHA384, HMACSHA512 - Use the functions SHA-256, SHA-384, and SHA-512 of the SHA-2 family. SHA-2 was published in 2001. The output hash lengths are 256, 384, and 512 bits, respectively,as the hash functions’ names indicate.

提交回复
热议问题