Skip to content

Commit

Permalink
Init commit
Browse files Browse the repository at this point in the history
  • Loading branch information
amir20 committed Nov 7, 2017
0 parents commit c0205fa
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test.go
@@ -0,0 +1,42 @@
package main

import (
"os"
"bytes"
"encoding/binary"
"crypto/sha256"
"math/big"
)

func main() {
bytes := argToBytes()
total := len(bytes)

buffer := make([]byte, total+8)
copy(buffer, bytes)

threshold := new(big.Int)
threshold.SetString("00000099999999999999999999999999999999999999999999999999999999999999999999999", 10)

for i := int64(0); i < 1<<63-1; i++ {
binary.PutVarint(buffer[total:], i)
sum := sha256.Sum256(buffer)

value := new(big.Int)
value.SetBytes(sum[:])

if value.Cmp(threshold) < 0 {
println("Found match", value.String())
break
}
}
}

func argToBytes() []byte {
var buffer bytes.Buffer
for i := 1; i < len(os.Args); i++ {
buffer.WriteString(os.Args[i])
}

return buffer.Bytes()
}

0 comments on commit c0205fa

Please sign in to comment.