aboutsummaryrefslogblamecommitdiffstats
path: root/commons/hash.go
blob: 03fa53f7dd499714b1e2017aa289ba0edad5f10a (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
















                                                   
package commons

import (
	"crypto/sha1"
	"fmt"
	"strconv"
)

func GitHash(t string, b []byte) string {
	h := []byte(t)
	h = append(h, ' ')
	h = strconv.AppendInt(h, int64(len(b)), 10)
	h = append(h, 0)
	h = append(h, b...)

	return fmt.Sprintf("%x", sha1.Sum(h))
}