Skip to content

Instantly share code, notes, and snippets.

@komatzz
Created April 24, 2017 13:57
Show Gist options
  • Select an option

  • Save komatzz/8aada980a4628d02d8ed8eeb05a50ea4 to your computer and use it in GitHub Desktop.

Select an option

Save komatzz/8aada980a4628d02d8ed8eeb05a50ea4 to your computer and use it in GitHub Desktop.
PHP で生成したパスワードハッシュが Python でマッチするか確認 ref: http://qiita.com/komatzz/items/3da52082bec5cf681a47
password_hash('password', PASSWORD_DEFAULT);
// $2y$10$BN2hH0B3gnZceNlW1JXiNOUN8NWybLlfqZh6WQ/imah4htM8fktFW
password_hash('password', PASSWORD_BCRYPT);
// $2y$10$CuZkO0N29B1YtHHI9mwvIOCSUitQh4ptyfxYWvHhHoHHP2GZqC5Ga
import bcrypt
password = b'password'
phpHash = '$2y$10$BN2hH0B3gnZceNlW1JXiNOUN8NWybLlfqZh6WQ/imah4htM8fktFW'
if bcrypt.checkpw(password, phpHash):
print("It Matches!")
else:
print("It Does not Match :(")
# It Matches!
salt = bcrypt.gensalt(rounds=10, prefix=b'2a')
password = b'password'
hashed = bcrypt.hashpw(password, salt)
define("PASSWORD_DEFAULT", 1);
define("PASSWORD_BCRYPT", 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment