9 // 20-byte SHA1 hash used for info and pieces.
12 func (h Hash) Bytes() []byte {
16 func (h Hash) AsString() string {
20 func (h Hash) HexString() string {
21 return fmt.Sprintf("%x", h[:])
24 func (h *Hash) FromHexString(s string) (err error) {
26 err = fmt.Errorf("hash hex string has bad length: %d", len(s))
29 n, err := hex.Decode(h[:], []byte(s))
39 func NewHashFromHex(s string) (h Hash) {
40 err := h.FromHexString(s)
47 func HashBytes(b []byte) (ret Hash) {
50 copy(ret[:], hasher.Sum(nil))