Last active
December 15, 2017 18:59
-
-
Save cliffom/a520f8de4564142b252939b847a492d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/sha256" | |
"fmt" | |
"io/ioutil" | |
"os" | |
"strconv" | |
) | |
func main() { | |
iterations, err := strconv.Atoi(os.Args[1]) | |
if err != nil { | |
iterations = 1 | |
} | |
data, _ := ioutil.ReadFile("rand.txt") | |
hash := getHash(data, iterations) | |
fmt.Printf("%x\n", hash) | |
} | |
func getHash(data []byte, iterations int) []byte { | |
for i := 0; i < iterations; i++ { | |
hash := sha256.New() | |
hash.Write(data) | |
data = hash.Sum(nil) | |
} | |
return data | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment