# Parallel brute force

```ruby
func invert_sha256(hash) {

    var letters = @('a'..'z')

    var job = func (prefix, hash) {
        variations_with_repetition(letters, 4, {|*a|
            var s = join('', prefix, a...)
            return s if (s.sha256 == hash)
        })
        return nil
    }

    letters.map {|prefix|
        job.ffork(prefix, hash)
    }.each {|f|
        with (f.wait) { return _ }
    }
}

var tests = %w(
  1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad
  3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b
  74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f
)

tests.each {|t|
    var phrase = invert_sha256(t)
    say "#{t} : #{phrase}"
}
```

## Output:

```
1115dd800feaacefdf481f1f9070374a2a81e27880f187396db67958b207cbad : zyzzx
3a7bd3e2360a3d29eea436fcfb7e44c735d117c42d1c1835420b6b9942dd4f1b : apple
74e1bb62f8dabb8125a58852b63bdf6eaef667cb56ac7f7cdba6d7305c50a22f : mmmmm
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://trizen.gitbook.io/sidef-lang/programming_tasks/p/parallel_brute_force.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
