Skip to content

Instantly share code, notes, and snippets.

@jlandure
Created August 2, 2016 13:02
Show Gist options
  • Select an option

  • Save jlandure/0c521fd866c22251b73d82a10b22c320 to your computer and use it in GitHub Desktop.

Select an option

Save jlandure/0c521fd866c22251b73d82a10b22c320 to your computer and use it in GitHub Desktop.
Golang hash test
package main
import (
"crypto/sha256"
"fmt"
"time"
)
func main() {
input := "Lorem Ipsum dolor sit Amet"
input = "0100000081cd02ab7e569e8bcd9317e2fe99f2de44d49ab2b8851ba4a308000000000000e320b6c2fffc8d750423db8b1eb942ae710e951ed797f7affc8892b0f1fc122bc7f5d74df2b9441a42a14695"
done := make(chan struct{})
var nb = 0
go func() {
for {
sha_256 := sha256.New()
sha_256.Write([]byte(input))
sha_256.Write([]byte(sha_256.Sum(nil)))
fmt.Printf("[%d] sha256:\t%x\n", nb, sha_256.Sum(nil))
nb++
}
}()
select {
case <-time.After(1 * time.Second):
fmt.Println("Something took to long, I quit !")
return
case <-done:
fmt.Println("It's done ! See ya !")
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment