Parallel brute force: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 1,408: | Line 1,408: | ||
zyzzx 1115DD800FEAACEFDF481F1F9070374A2A81E27880F187396DB67958B207CBAD |
zyzzx 1115DD800FEAACEFDF481F1F9070374A2A81E27880F187396DB67958B207CBAD |
||
Done</pre> |
Done</pre> |
||
=={{header|Nim}}== |
|||
{{libheader|Nimcrypto}} |
|||
Using a thread for each starting character. |
|||
<lang Nim>import strutils, threadpool |
|||
import nimcrypto |
|||
const |
|||
# List of hexadecimal representation of target hashes. |
|||
HexHashes = ["1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad", |
|||
"3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b", |
|||
"74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f"] |
|||
# List of target hashes. |
|||
Hashes = [MDigest[256].fromHex(HexHashes[0]), |
|||
MDigest[256].fromHex(HexHashes[1]), |
|||
MDigest[256].fromHex(HexHashes[2])] |
|||
Letters = 'a'..'z' |
|||
proc findHashes(a: char) = |
|||
## Build the arrays of five characters starting with the value |
|||
## of "a" and check if their hash matches one of the targets. |
|||
## Print the string and the hash value if a match is found. |
|||
var s: array[5, char] |
|||
for b in Letters: |
|||
for c in Letters: |
|||
for d in Letters: |
|||
for e in Letters: |
|||
s = [a, b, c, d, e] |
|||
let h = sha256.digest(s) |
|||
for i, target in Hashes: |
|||
if h == target: # Match. |
|||
echo s.join(), " → ", HexHashes[i] |
|||
# Launch a thread for each starting character. |
|||
for a in Letters: |
|||
spawn findHashes(a) |
|||
sync()</lang> |
|||
{{out}} |
|||
<pre>apple → 3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b |
|||
mmmmm → 74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f |
|||
zyzzx → 1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |