![]() Returns a list with the 3 answers." ( -> hex-hashes ( map hex->bytes ) convert the hex strings to bytes ( pmap parallel map the checker-fn ( fn ( let ( some ( partial check-candidate target-bytes sha256 ) ( selections space 5 ))))))) Otherwise returns nil." ( let ( when ( Arrays/equals target candidate-hash ) ( let ( println "Answer found for:" ( bytes->hex candidate-hash ) "=>" answer ) answer )))) ( defn sha256-brute-force "Top level function. If it does, returns that hash as a hex-encoded String. append ( format "x" ( aget bs idx ))))))) MAIN LOGIC = ( defn check-candidate "Checks whether the SHA256 hash of (a list of 5 bytes), matches. toString ^ StringBuilder ( areduce bs idx ret ( StringBuilder. charAt hex ( inc i )) 16 )))) ( range 0 len 2 )) ret )) ( defn bytes->hex "Converts a byte-array to a hex string." (. charAt hex i ) 16 ) 4 ) ( Character/digit (. ![]() digest md bs )) ( defn char-range "Helper fn for easily producing character ranges." ( map char ( range ( int start ) ( inc ( int end ))))) ( def low-case-eng-bytes "Our search-space (all lower case english characters converted to bytes)." ( map byte ( char-range \a \z ))) ( defn hex->bytes "Converts a hex string to a byte-array." ^ bytes ( let ( run! ( fn ( aset ret ( / i 2 ) ^ byte ( unchecked-add-int ( bit-shift-left ( Character/digit (. ( ns rosetta.brute-force ( :require ]) ( :import )) ( def targets length = 5 ) HELPER/UTIL fns = ( defn digest "Given a byte-array returns its hash (also a byte-array)." ^ bytes (. parabrutfor #include #include #include #include #include typedef unsigned char byte int matches ( byte * a, byte * b ) $ gcc -o parabrutfor parabrutfor.c -fopenmp -lssl -lcrypto // $ export OMP_NUM_THREADS=4 // $. 4 ) := B2
0 Comments
Leave a Reply. |