13
11

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 5 years have passed since last update.

ElixirにComeoninモジュールでパスワードを暗号化

13
Last updated at Posted at 2015-05-22

Elixirの中で、Comeoninモジュールでパスワードを暗号化する

mix.exsファイルのdeps関数部分

defp deps do
  [
    {:comeonin, "~> 1.0"}
  ]
end

実行

$ mix deps.get
$ iex -S mix

使用例

iex(6)> hash = Comeonin.Bcrypt.hashpwsalt("123456")
"$2b$12$lkDBNAh/yIeYi8tkulPvqO/Y3rTY3Clik3rt7iku6wTcItkob/3PO"
iex(7)> b = Comeonin.Bcrypt.checkpw("123456", hash)
true
iex(8)> b = Comeonin.Bcrypt.checkpw("123", hash)
false

hashpwsaltはランダムのsaltを使ってパスワードのハッシュします。

13
11
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
13
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?