Created
April 24, 2017 13:57
-
-
Save komatzz/8aada980a4628d02d8ed8eeb05a50ea4 to your computer and use it in GitHub Desktop.
PHP で生成したパスワードハッシュが Python でマッチするか確認 ref: http://qiita.com/komatzz/items/3da52082bec5cf681a47
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| password_hash('password', PASSWORD_DEFAULT); | |
| // $2y$10$BN2hH0B3gnZceNlW1JXiNOUN8NWybLlfqZh6WQ/imah4htM8fktFW | |
| password_hash('password', PASSWORD_BCRYPT); | |
| // $2y$10$CuZkO0N29B1YtHHI9mwvIOCSUitQh4ptyfxYWvHhHoHHP2GZqC5Ga |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| salt = bcrypt.gensalt(rounds=10, prefix=b'2a') | |
| password = b'password' | |
| hashed = bcrypt.hashpw(password, salt) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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