LoginSignup
0
2

More than 5 years have passed since last update.

NetCommons3のパスワード暗号化方法

Posted at

下記コードは暗号化再現コード。実際にはCakePHP2の Security::hash() を使ってるのでこのとおりじゃないですが…

// $salt app/Config/application.ymlにあるSecurity.salt app/Config/core.phpにあるSecurity.saltじゃないので注意。 
// $password 入力したパスワード
$encrypt = hash('sha512', $salt . $password);

このように app/Config/application.yml に記述してある salt を使うのでこのファイルを上書き等で紛失すると、一切ログインできなくなります。

開発環境等でMySQLのクエリでパスワードをまとめて更新するなら下記クエリで。

UPDATE users SET `password`=sha2('{{Salt}}{{Password}}', 512);
0
2
13

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2