This commit is contained in:
2026-02-02 23:00:03 +03:00
commit be8ea42808
27 changed files with 3598 additions and 0 deletions

18
metadata.go Normal file
View File

@@ -0,0 +1,18 @@
package main
import (
"github.com/zeebo/bencode"
)
type TorrentMetadata struct {
Info bencode.RawMessage `bencode:"info"`
}
func getTorrentInfoHash(torrent []byte) (string, error) {
torrentMetadata := &TorrentMetadata{}
if err := bencode.DecodeBytes(torrent, torrentMetadata); err != nil {
return "", err
}
return toSha1(torrentMetadata.Info), nil
}