Skip to content

Instantly share code, notes, and snippets.

@mickelsonm
Created October 31, 2015 06:20
Show Gist options
  • Save mickelsonm/03fd911f546d40875a2a to your computer and use it in GitHub Desktop.
Save mickelsonm/03fd911f546d40875a2a to your computer and use it in GitHub Desktop.
Go - String to Sha1
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