Skip to content

Instantly share code, notes, and snippets.

@micrypt
Created July 25, 2012 18:39
Show Gist options
  • Save micrypt/3177794 to your computer and use it in GitHub Desktop.
Save micrypt/3177794 to your computer and use it in GitHub Desktop.
package git
import "fmt"
import "crypto/sha1"
import "io"
import "strconv"
func getGitSha(data) string {
h := sha1.New()
io.WriteString(h, "blob "+strconv.Itoa(len(data)+1)+"\x00"+data+"\n")
return fmt.Sprintf("% x", h.Sum(nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment