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?

エントロピー計算付きパスワード強度チェッカー + 生成器を作った

0
Posted at

作ったもの

Password Strengthhttps://sen.ltd/portfolio/password-strength/

スクリーンショット

  • 5 段階の強度バー
  • ビット単位のエントロピー表示
  • クラック時間推定(秒〜世紀)
  • 改善提案を箇条書きで表示
  • 500+ 個の頻出パスワードブロックリスト
  • crypto.getRandomValues ベースの安全な生成器
  • パスフレーズモード(ランダムな 4-6 単語)

vanilla JS、ゼロ依存、ビルド不要node --test で 67 ケース。

エントロピー計算

let poolSize = 0;
if (/[a-z]/.test(pw)) poolSize += 26;
if (/[A-Z]/.test(pw)) poolSize += 26;
if (/\d/.test(pw)) poolSize += 10;
if (/[^a-zA-Z0-9]/.test(pw)) poolSize += 32;
return pw.length * Math.log2(poolSize);

上限値ではあるが、長さ × 文字種の比較には有用。

クラック時間

10^10 guesses/sec を仮定(GPU 総当たり相当):

  • 40 ビット → 110 秒
  • 60 ビット → 3.6 年
  • 80 ビット → 千年以上

NIST の目安は 64 ビット以上。80 ビット以上が実用的な安全マージン。

Math.random は絶対ダメ

Math.random() は現在時刻シードで予測可能。パスワード生成には crypto.getRandomValues:

const buf = new Uint32Array(1);
crypto.getRandomValues(buf);
return buf[0] % max;

ブロックリスト

500+ 個の頻出パスワード(password / 123456 / qwerty / Password123! など)にヒットしたら、どれだけエントロピーが高くてもスコアを 0 にキャップ。

シリーズ

100+ 公開ポートフォリオ シリーズの #77 です。

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?