使用salt将密码存储为SHA512

时间:2015-12-19 15:31:56

标签: php yii yii2

我想使用SHA512(盐渍)存储我的密码。目前我将其存储为MD5。有了这个我的登录功能不起作用。

public function actionUserForm()
{
        $model=new UserForm;
        $newUser = new UserForm;

        // if it is ajax validation request
        if(isset($_POST['ajax']) && $_POST['ajax']==='userForm')
        {
                echo CActiveForm::validate($model);
                Yii::app()->end();
        }

        // collect user input data
        if(isset($_POST['UserForm']))
        {
                $model->attributes=$_POST['UserForm'];
                 $pass = md5($model->password);
                $newUser->password = $model->pass;
                $newUser->email = $model->email;
                // $newUser->joined = date('Y-m-d');

               if ($model->save())
        $this->redirect("login");   

        }
        // display the register form
        $this->render('userForm',array('model'=>$model));
}

1 个答案:

答案 0 :(得分:-2)

将您的代码更改为......密码分配中存在一些错误....

<fo:block>
The image (
  <fo:external-graphic content-width="100pt" content-height="50pt" scaling="non-uniform" src="images/fop.jpg"/>
) has non-uniform scaling.
</fo:block>

<fo:block>
The image (
<fo:external-graphic content-width="50pt" content-height="100pt" scaling="non-uniform" src="images/fop.jpg"/>
) has non-uniform scaling.
</fo:block>

<fo:block>
The image (
<fo:external-graphic content-width="100pt" content-height="75pt" scaling="uniform" src="images/fop.jpg"/>
) has uniform scaling.
</fo:block>

<fo:block>
The image (
<fo:external-graphic content-width="75pt" content-height="100pt" scaling="uniform" src="images/fop.jpg"/>
) has uniform scaling.
</fo:block>

<fo:block>
The image (
<fo:external-graphic width="75pt" height="100pt" content-width="scale-to-fit" content-height="scale-to-fit" src="images/fop.jpg"/>
) is scaled to fit the viewport.
</fo:block>

密码不是使用md5字符串赋值..