2
0
mirror of synced 2025-02-24 14:48:27 +00:00

metainfo: Add HashBytes

This commit is contained in:
Matt Joiner 2016-05-03 21:34:20 +10:00
parent e0451b0728
commit 533f01147d

View File

@ -1,6 +1,7 @@
package metainfo package metainfo
import ( import (
"crypto/sha1"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
) )
@ -34,3 +35,10 @@ func (h *Hash) FromHexString(s string) (err error) {
} }
return return
} }
func HashBytes(b []byte) (ret Hash) {
hasher := sha1.New()
hasher.Write(b)
copy(ret[:], hasher.Sum(nil))
return
}