Created
October 31, 2015 06:20
-
-
Save mickelsonm/03fd911f546d40875a2a to your computer and use it in GitHub Desktop.
Go - String to Sha1
This file contains hidden or 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/sha1" | |
"encoding/hex" | |
"fmt" | |
) | |
func main() { | |
for i := 0; i < 100; i++ { | |
fmt.Println(StringToSha1("password"+string(i))) | |
} | |
} | |
var ( | |
h = sha1.New() | |
) | |
func StringToSha1(val string) string { | |
h.Write([]byte(val)) | |
return hex.EncodeToString(h.Sum(nil)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment