私は現在、私のユーザー登録コードをチェックしています。私が今注目している部分は、パスワードのハッシュ部分です。関数を一度ロードして変数に格納するにはどうすればよいですか?
私が行うのは、configファイルからstatic_saltを取得し、mt_rand()を使ってdynamic_saltを生成することです。私がやりたいことは、このdynamic_saltをデータベースに保存することです。
dynamic_salt()メソッドをcreateメソッドに渡してデータベースのテーブルのsaltカラムに送信すると、メソッドが再び実行され、myメソッドで生成されたものとは異なる結果が作成されますhashed()メソッド
私が達成しようとしていることを達成する最良の方法は、可能ならば私に例を教えてください。
public function create() {
$dbcolumn->password = $this->hashed();
$dbcolumn->salt = $this->dynamic_salt;
$this->db->insert('users', $dbcolumn);
}
public function dynamic_salt() {
$get_dynamic_salt = mt_rand();
return $get_dynamic_salt;
}
public function hashed() { //hashing method, that also makes
// sha1 and salt password
$static_salt = $this->config->item('encryption_key'); //grab static salt from config file
$dynamic_salt = $this->dynamic_salt();
$password = $this->encrypt->sha1($this->input->post('password')); //encrypt user password
$hashed = sha1($dynamic_salt . $password . $static_salt);
return $hashed;
}
は$ dbcolumn-> salt = $ this-> dynamic_saltを編集しました。 – LondonGuy
私は動的塩を使わないように言われていて、データベースに塩を保存するのは危険です。 – LondonGuy
'$ dbcolumn-> salt = $ this-> dynamic_salt();'なぜこのすべてを使用するのでしょうか?なぜ単にmd5を使用してパスワード(英数字、min_lengthなど)に制限を設定するのではなく、[CI](http://codeigniter.com/user_guide/libraries/form_validation.html)を使用しているので、 )!! – ifaour