Last active
August 29, 2015 13:56
-
-
Save tenten0213/8910211 to your computer and use it in GitHub Desktop.
数字6桁パスワードのハッシュ値の総当たり
This file contains 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
require 'digest/md5' | |
hash = "4b364677946ccf79f841114e73ccaf4f" | |
salt = "hoge$" | |
0.upto(999999) { |num| | |
pass = "%06d"%num | |
digest = Digest::MD5.new.update(salt + pass).to_s | |
if digest == hash | |
puts "Solved: #{pass}" | |
end | |
} |
time ruby jal.rbで実行すれば良いからbenchmark消した。
- 0から999999の範囲指定に変更
- 書式を"%6d"から"%06d"に変更(元の書式だと0埋めにならずスペース埋めになる
- 先に$をsaltに付与するように変更
formatとmd5の取り方を変えたら半分程度まで早くなった模様。
勉強になります。
https://gist.github.com/Sheile/8949613
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
パスワード問合せシステムを作る (clojureのreducers) - Qiitaと徳丸浩の雑記帳: 数字6桁パスワードのハッシュ値の総当たり、PHPなら約0.25秒で終わるよを参考に、Rubyで書いてみた