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) String() string {
24 func (h Hash) HexString() string {
25 return fmt.Sprintf("%x", h[:])
28 func (h *Hash) FromHexString(s string) (err error) {
30 err = fmt.Errorf("hash hex string has bad length: %d", len(s))
33 n, err := hex.Decode(h[:], []byte(s))
43 func NewHashFromHex(s string) (h Hash) {
44 err := h.FromHexString(s)
51 func HashBytes(b []byte) (ret Hash) {
54 copy(ret[:], hasher.Sum(nil))