0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Rails】encrypted_passwordを作りたい

Posted at

自分用に記録

文字列からencrypted_passwordに保存する用のハッシュに変換する。

bcrypt.rb
password = 'Password1234!'

::BCrypt::Password.create(password).to_s

createに:costを数値で設定すればパスワードの強度を変更できるらしい。(4~31)
数値小さければ計算リソース少なく、大きければ強度高く。

MySQLWorkbenchから直接ユーザー登録する際などに、rails cで作る時などに使ってます。
また大量ユーザーをCSVで取り込む処理などでパスワード設定する時なども使えるかもです。

0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?