Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
21
Task/Parallel-brute-force/Zkl/parallel-brute-force-1.zkl
Normal file
21
Task/Parallel-brute-force/Zkl/parallel-brute-force-1.zkl
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
15
Task/Parallel-brute-force/Zkl/parallel-brute-force-2.zkl
Normal file
15
Task/Parallel-brute-force/Zkl/parallel-brute-force-2.zkl
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
hashes:=T("3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b",
|
||||
"74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f",
|
||||
"1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad");
|
||||
// convert hex strings to binary; cuts down conversions during crack
|
||||
fcn hex2binary(s){ s.pump(Data,Void.Read,fcn(a,b){ (a+b).toInt(16) }) }
|
||||
hashes:=hashes.apply(hex2binary);
|
||||
|
||||
hashes2go.set(hashes.len()); // number of codes to crack
|
||||
num,xtra := 26/THREADS, 26%THREADS; // try for the most even spread over threads
|
||||
s:=0; do(THREADS){ // start threads
|
||||
n:=num + ((xtra-=1)>=0);
|
||||
crack.launch(s.toInt(),n,hashes);
|
||||
s+=n;
|
||||
}
|
||||
hashes2go.waitFor(0); // wait until all cracked, just exit, OS kills threads
|
||||
Loading…
Add table
Add a link
Reference in a new issue