package main
import (
"bytes"
"crypto/sha256"
"encoding/hex"
"fmt"
)
var (
_chars = []byte("0123456789abcdef")
_names = []string{"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "a", "b", "c", "d", "e", "f"}
_size = len(_chars)
)
func main() {
hexsum := make([]byte, 64)
for i1 := 0; i1 < _size; i1++ {
for i2 := 0; i2 < _size; i2++ {
for i3 := 0; i3 < _size; i3++ {
for i4 := 0; i4 < _size; i4++ {
for i5 := 0; i5 < _size; i5++ {
for i6 := 0; i6 < _size; i6++ {
for i7 := 0; i7 < _size; i7++ {
s := fmt.Sprintf("The SHA256 for this sentence begins with: %s, %s, %s, %s, %s, %s and %s.", _names[i1], _names[i2], _names[i3], _names[i4], _names[i5], _names[i6], _names[i7])
sum := sha256.Sum256([]byte(s))
hex.Encode(hexsum, sum[:])
prefix := []byte{_chars[i1], _chars[i2], _chars[i3], _chars[i4], _chars[i5], _chars[i6], _chars[i7]}
if bytes.HasPrefix(hexsum, prefix) {
fmt.Printf("%s\n", s)
fmt.Printf("%s\n", hexsum)
}
}
}
}
}
}
}
}
}
Takes a few minutes on common consumer hardware. There's exactly one hit.(Easiest optimization is wrapping the loop body in a goroutine. GOEXPERIMENT=loopvar really makes this nicer btw.)
The reply is obviously more interesting, need to come up with a lot of variations.