Yii2 Username and password encryption(Yii2 用户名密码加密)
问题描述
几天前我扫描了我的 yii2 应用程序,并注意到登录表单中的用户名和密码是在没有任何加密的情况下发布的.我怎样才能让我的用户名和密码更安全?我知道 yiihelpersSecurity::encrypt($data, $secretKey)
会加密数据,我们也可以解密.但是如何在像登录表单这样的视图中使用它?
这是我的登录表单
'login-form']);?><?= $form->field($model, 'username') ?><?= $form->field($model, 'password')->passwordInput() ?><div class="form-group"><?= Html::submitButton('登录', ['class' => 'btn btn-info']) ?>
<?php ActiveForm::end();?>
这里如何处理用户输入数据的加密?
正如 Sisko78 在其评论中声称的那样,客户端的散列密码在安全性方面没有太大帮助,但可以做到很多危害(如果有人在他们的浏览器中完全使用 Javascript,他们通常会被搞砸,因为您的服务器将无法正确处理未散列的数据).
我在这个问题上问了非常相似的问题,并得到了这个很好的答案.一般来说:
<块引用>从攻击者的角度来看,无论您发送纯文本密码还是 MD5 哈希,都没有太大区别 (...)
这个答案包括对 MD5 哈希的引用,因为我是专门针对这个问题询问的.但是,它与 MD5 现在被视为非常不安全的事实没有任何关系.就您的(我的)问题而言,使用任何类型的客户端密码都与根本不散列密码一样不安全.而且唯一真正安全的选择是使用 HTTPS 协议.阿门.
I had scanned my yii2 application few days before and noted that username and passwords from the login form is posting without any encryption. How can i make my username and password more secure?I know yiihelpersSecurity::encrypt($data, $secretKey)
will encrypt the data and similiary we can decrypt it. But how to use it in a view like login form?
This is my login form
<?php $form = ActiveForm::begin(['id' => 'login-form']); ?>
<?= $form->field($model, 'username') ?>
<?= $form->field($model, 'password')->passwordInput() ?>
<div class="form-group">
<?= Html::submitButton('Login', ['class' => 'btn btn-info']) ?>
</div>
<?php ActiveForm::end(); ?>
How to handle the encryption of user entered data here?
As Sisko78 claims in its comment, hashing password on client side won't do much help in terms of security, but can do a lot of harm (if someone turns of Javascript at all in their browser, they're generally screwed, as your server won't be able to correctly process not hashed data).
I have asked very similar question on this matter and was given this great answer. In general:
From the attacker's standpoint, whether you send a plain text password or a MD5 hash or it doesn't make much difference (...)
This answer includes reference to MD5 hash, because I asked specifically for this one. But, it does not have any relation to the fact, that MD5 is now treated as very insecure. In terms of your (mine) question, using any kind of client-side password hasing is as insecure as not hashing password at all. And the only really secure option is to use HTTPS protocol. Amen.
这篇关于Yii2 用户名密码加密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Yii2 用户名密码加密
基础教程推荐
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01