]> Sergey Matveev's repositories - btrtrc.git/blobdiff - metainfo/hash.go
Drop support for go 1.20
[btrtrc.git] / metainfo / hash.go
index 46cb3e8d09df3e198cc0a4c9e41a05d2d1ad87c8..39daf6f3619b0d48cf16e2e3816edcacf07042bf 100644 (file)
@@ -1,18 +1,16 @@
 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
+)