DevToolBox

Bcrypt Hash Generator

Generate and verify securely salted bcrypt password hashes entirely in your browser. bcryptハッシュを外部送信なしで生成・検証します。

ラウンド数が上がるほど計算に時間がかかります (pure JS実装のため純正Cバインディングより低速)。

How to Use the Bcrypt Hash Generator

In Generate mode, enter a test password, choose cost factor 10, 12, or 14, and select "ハッシュを生成". The tool creates a fresh random salt internally and shows the complete 60-character bcrypt string, its embedded cost, and its salt. In Verify mode, enter a plaintext password and an existing bcrypt hash to check them with bcrypt's comparison routine.

What Is bcrypt?

bcrypt is an adaptive password-hashing function designed in 1999 by Niels Provos and David Mazières. It is based on the Blowfish cipher and combines a random salt with a configurable cost factor. The salt prevents identical passwords from producing identical stored values, while the cost makes every password guess deliberately expensive and can be increased as hardware becomes faster.

bcrypt vs PBKDF2 vs Argon2

bcrypt is mature, broadly supported, and practical for established web frameworks. PBKDF2 is also valid and is especially useful when NIST or FIPS-aligned implementations are required. Argon2id is memory-hard and is generally preferred for new systems when a well-maintained implementation is available. Choose for your platform and compliance needs, then benchmark on production hardware.

Choosing a Cost Factor

A cost factor is logarithmic: increasing it by one roughly doubles the required work. OWASP's baseline is at least 10, while many frameworks default to 10 or 12. Select the highest value your authentication service can sustain without unacceptable latency or denial-of-service risk, and re-evaluate it over time.

Bcryptハッシュ生成・検証ツールについて

bcryptは、Blowfish暗号を基礎としてNiels ProvosとDavid Mazièresが1999年に設計した適応型パスワードハッシュ関数です。ランダムソルトと調整可能なコストをハッシュ文字列自体に含みます。本ツールではbcrypt-tsの非同期APIを使い、UIを止めにくい形で生成・検証します。

bcrypt・PBKDF2・Argon2の使い分け

  • bcrypt -- 実績とフレームワーク互換性を重視するWebシステム向け。72バイト制限に注意します。
  • PBKDF2 -- NIST/FIPS準拠が必要な環境向け。PBKDF2版ツールでも確認できます。
  • Argon2id -- メモリハード性を備え、新規システムで信頼できる実装を利用できる場合の第一候補です。

実務での活用例

  • 実装確認 -- テスト値でアプリケーション側の出力・検証処理と突き合わせる
  • 移行調査 -- 既存ハッシュからバージョンとコストを確認する
  • 性能見積もり -- コストごとの体感差を本番ベンチマーク設計に役立てる

よくある落とし穴と対処 / Common Pitfalls

落とし穴 / Pitfall問題 / Problem対処 / Fix
72バイト制限を無視する
Ignoring the 72-byte limit
異なる長い入力が切り詰め後に同じになる
Long inputs can become equivalent after truncation
UTF-8バイト長を確認する
Check UTF-8 byte length
$2a$$2b$$2y$を誤解する
Misreading version prefixes
互換性を誤判断する
Migration assumptions can fail
ライブラリの対応を確認し、勝手に書き換えない
Check support; never rewrite blindly
コストが低すぎる
Cost too low
総当たり耐性が不足する
Guessing is too inexpensive
最低10を出発点に再評価する
Start at 10 or above and revisit
コストが高すぎる
Cost too high
遅延やDoSリスクを増やす
Latency and DoS risk increase
本番環境でベンチマークする
Benchmark on production hardware
文字列を単純比較する
Comparing hash strings directly
新しいソルトで出力が変わり、独自比較はタイミング情報も漏らし得る
Fresh salts differ; custom checks may leak timing
compare()を使う
Use compare()

言語別コード例 / Code Examples

JavaScript (bcrypt-ts)

import { hash, compare } from "bcrypt-ts";
const stored = await hash("test-password", 12);
const valid = await compare("test-password", stored);

Python (bcrypt)

import bcrypt
stored = bcrypt.hashpw(b"test-password", bcrypt.gensalt(rounds=12))
valid = bcrypt.checkpw(b"test-password", stored)

Node.js (bcrypt)

const bcrypt = require("bcrypt");
const stored = await bcrypt.hash("test-password", 12);
const valid = await bcrypt.compare("test-password", stored);

Go (golang.org/x/crypto/bcrypt)

stored, err := bcrypt.GenerateFromPassword([]byte("test-password"), 12)
if err != nil { log.Fatal(err) }
err = bcrypt.CompareHashAndPassword(stored, []byte("test-password"))

PHP (password_hash)

$stored = password_hash("test-password", PASSWORD_BCRYPT, ["cost" => 12]);
$valid = password_verify("test-password", $stored);

生成例 / Before & After

入力 / Before:
password = "test-password"
cost factor = 10

出力 / After (例。ソルトが毎回変わるため結果も毎回変わります):
$2b$10$N9qo8uLOickgx2ZMRZoMyeIjZAgcfl7p92ldGxad68LJZdL17lhWy

構造: $2b$ = version, 10 = cost, next 22 chars = salt, remainder = hash

Why browser-only?

A password is one of the most sensitive strings you will ever type. If a hash generator runs server-side, that plaintext may pass through someone else's network, memory, or logs. This tool uses bcrypt-ts in your browser, including Web Crypto API randomness for salt generation: nothing is submitted by the tool and nothing is stored. You can confirm this in the Network panel. Even so, prefer disposable test values over real production passwords.

パスワードは最も機密性の高い文字列です。本ツールはソルト生成・ハッシュ計算・検証をブラウザ内で完結させ、入力を外部へ送信しません。安全な乱数生成はbcrypt-ts内部のWeb Crypto API (crypto.getRandomValues)に任せています。念のため、本番で使用中のパスワードではなくテスト値を利用してください。

開発をもっと効率的に

PR