package metainfo
-import "fmt"
+import (
+ "github.com/anacrolix/torrent/types/infohash"
+)
-// 20-byte SHA1 hash used for info and pieces.
-type Hash [20]byte
+// This type has been moved to allow avoiding importing everything in metainfo to get at it.
-func (h Hash) Bytes() []byte {
- return h[:]
-}
+const HashSize = infohash.Size
-func (h *Hash) AsString() string {
- return string(h[:])
-}
+type Hash = infohash.T
-func (h Hash) HexString() string {
- return fmt.Sprintf("%x", h[:])
-}
+var (
+ NewHashFromHex = infohash.FromHexString
+ HashBytes = infohash.HashBytes
+)