doula2426 2017-03-31 09:53
浏览 97
已采纳

密码上限/下限/数字/符号规则是否与盐渍密码无关

I'm working on a basic password system using the password_hash function, and was wondering about the need for the familiar 'Choose a password with uppercase, lowercase, number and symbol' rules.

PHP's password_hash automatically generates a strong random salt, adds it to the password and hashes the result. Then it outputs a final string that has three sections:

  • The algorithm used and number of times it encoded the data
  • The random salt
  • The resulting hash

These sections are concatenated into a single string:

For example a password 'password' is processed as follows:

$password = 'password';
//using password_hash with Blowfish encryption
    $hashtext = password_hash($password, PASSWORD_BCRYPT);

//user tries to log in with password $login
//which is hashed with the same encoder and salt as contained in $hashtext
if (password_verify ($login , $hashtext )) {
        echo 'Password good';
    }else {
        echo 'Wrong password';
    }

Assume that the $hashtext is stored in a database which later is hacked so that this is read and the encoding type and salt is known. Is the strength of the security now based solely on the strength of the password? ie the hacker sets up a function with the same encoder and salt value and runs through a dictionary of possible passwords until the resultant output is the same as $hashtext, confirming that the dictionary value being checked is the original password.

I assume that the randomness and complexity of the salt alone makes this process probably impractical, but would also making the original password p@55Word really add much to the security?

Yes, I realise that those are terrible choices for passwords!

Any help would be appreciated!

Many thanks, Kw

  • 写回答

1条回答 默认 最新

  • duanpo1498 2017-04-01 13:46
    关注

    Salting, key-stretching, and password complexity rules have their own purposes and are not related to each other. The password_hash() function...

    1. adds a salt, to prevent the usage of rainbow-tables
    2. makes the password hashing slow, so brute-forcing becomes much more expensive

    ➽ makes sure, that there is no easier way to find the plaintext password, than with brute-forcing.

    All these measures won't help if a user chooses a very weak password like 1234, because this is one of the first combinations an attacker will ever test. That's why password complexity rules where invented, in the hope that the users will choose stronger passwords.

    This leads to the question, if such password complexity rules really make the passwords stronger (but this is independend of questions about hashing techniques). Here the discussion becomes a bit opinion based.

    It is my own opinion, that complex rules will even decrease password security, because humans can't remember tons of strong passwords, and because they can interfere with good password schemes. People can get very inventive to circumvent such rules, the password Password-2017 will match most rules but is of course a very weak one. So my advice is to enforce only those two rules:

    1. Require a minimum length of 8 characters for a password.
    2. Make a list of the most common passwords and reject them. The minimum length will already rule out a lot of those passwords.
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥15 关于超局变量获取查询的问题
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集
  • ¥15 在启动roslaunch时出现如下问题
  • ¥15 汇编语言实现加减法计算器的功能
  • ¥20 关于多单片机模块化的一些问题