21 lines
917 B
Text
21 lines
917 B
Text
var [const] MsgHash=Import.lib("zklMsgHash");
|
|
var [const] gotEm=Atomic.Int(); // global signal for all threads
|
|
|
|
const THREADS=9, // how we will split task, THREADS<=26
|
|
CHR_a="a".toAsc();
|
|
|
|
fcn crack(c,n,hashes){ // thread
|
|
sha256:=MsgHash.SHA256; // the SHA-256 hash method, byte bucket
|
|
bytes,hash := Data(),Data().howza(0); // byte buckets to reduce garbage production
|
|
firstLtrs:=(c+CHR_a).walker(n);
|
|
ltrs:=CHR_a.walker; // iterator starting at 97/"a"
|
|
foreach a,b,c,d,e in (firstLtrs,ltrs(26),ltrs(26),ltrs(26),ltrs(26)){
|
|
if(not hashes2go) return(); // all cracked, stop, not really needed
|
|
bytes.clear(a,b,c,d,e); // recycle Data, faster than creating Strings
|
|
sha256(bytes,1,hash); // put hash in hash
|
|
if(hashes.holds(hash)){
|
|
println(bytes.text," --> ",hash.pump(String,"%02x".fmt));
|
|
hashes2go.dec(); // I cracked one, let mom thread know
|
|
}
|
|
}
|
|
}
|