Guest User

Untitled

a guest
Dec 17th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4. "crypto/sha256"
  5. "fmt"
  6. "io/ioutil"
  7. "os"
  8. "strconv"
  9. )
  10.  
  11. func main() {
  12. iterations, err := strconv.Atoi(os.Args[1])
  13. if err != nil {
  14. iterations = 1
  15. }
  16.  
  17. data, _ := ioutil.ReadFile("rand.txt")
  18. hash := getHash(data, iterations)
  19.  
  20. fmt.Printf("%x\n", hash)
  21. }
  22.  
  23. func getHash(data []byte, iterations int) []byte {
  24. for i := 0; i < iterations; i++ {
  25. hash := sha256.New()
  26. hash.Write(data)
  27. data = hash.Sum(nil)
  28. }
  29.  
  30. return data
  31. }
Add Comment
Please, Sign In to add comment