Created
February 10, 2014 12:22
-
-
Save ktakashi/8914937 to your computer and use it in GitHub Desktop.
JAL password hash
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 (rnrs) (crypto) (math) (time)) | |
(define target (hash MD5 (string->utf8 "hoge$567890"))) | |
(print target) | |
(define (solve) | |
(define md5-hash (hash-algorithm MD5)) | |
(define buf (make-bytevector (hash-size md5-hash))) | |
(define value (u8-list->bytevector | |
(append (map char->integer (string->list "hoge$")) | |
'(0 0 0 0 0 0)))) | |
(define offset (string-length "hoge$")) | |
(define (->solted-bv v) | |
(define len (bytevector-length value)) | |
(let loop ((i offset) (ch (string->list (number->string v)))) | |
(cond ((null? ch) value) | |
(else | |
(bytevector-u8-set! value i (char->integer (car ch))) | |
(loop (+ i 1) (cdr ch)))))) | |
(let loop ((i 0)) | |
(when (< i 1000000) | |
(hash-init! md5-hash) | |
(hash-process! md5-hash (->solted-bv i)) | |
(hash-done! md5-hash buf) | |
(if (bytevector=? target buf) | |
buf | |
(loop (+ i 1)))))) | |
(print "Solved: " (time (solve))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment