Versions in this module Expand all Collapse all v4 v4.2.2 May 25, 2026 Changes in this version + const CASCloudKey + const CASExtensionKey + const CASFileMD5Key + const CASSliceMD5Key + const CASSliceMD5sKey + const CASSliceSizeKey + const DefaultPieceSize + func BencodeDecode(data []byte) (interface{}, error) + func BencodeEncode(v interface{}) ([]byte, error) + func CopyAndHash(dst io.Writer, src io.Reader, hw *HashWriter) (int64, error) + func GenerateFromFile(filePath string) ([]byte, error) + func GenerateFromFileWithCAS(filePath string) ([]byte, error) + func GenerateFromReader(reader io.Reader, fileName string, fileSize int64, pieceSize int64) ([]byte, error) + func GenerateFromReaderWithCAS(reader io.Reader, fileName string, fileSize int64, pieceSize int64) ([]byte, error) + func GetMD5Str(data string) string + type CASInfo struct + Cloud string + FileMD5 string + SliceMD5 string + SliceMD5s []string + SliceSize int64 + func BuildCASInfoFromMD5s(fileMD5 string, sliceMD5s []string, sliceSize int64) *CASInfo + type HashWriter struct + func NewDefaultHashWriter() *HashWriter + func NewHashWriter(sliceSize, pieceSize int64) *HashWriter + func (hw *HashWriter) BuildTorrent(fileName string, fileSize int64) *Torrent + func (hw *HashWriter) BuildTorrentBytes(fileName string, fileSize int64) ([]byte, error) + func (hw *HashWriter) Finish() + func (hw *HashWriter) GetFileMD5() string + func (hw *HashWriter) GetPieceHashes() []byte + func (hw *HashWriter) GetSliceMD5(fileMD5 string) string + func (hw *HashWriter) GetSliceMD5s() []string + func (hw *HashWriter) GetTotalWritten() int64 + func (hw *HashWriter) Write(p []byte) (n int, err error) + type OrderedDict struct + Keys []string + Values map[string]interface{} + func NewOrderedDict() OrderedDict + func (d *OrderedDict) Get(key string) (interface{}, bool) + func (d *OrderedDict) Set(key string, value interface{}) + type Torrent struct + Announce string + AnnounceList [][]string + CAS *CASInfo + Comment string + CreatedBy string + CreationDate int64 + Info TorrentInfo + InfoHash []byte + func Decode(data []byte) (*Torrent, error) + func NewTorrent(name string, fileSize int64, fileMD5 string) *Torrent + func (t *Torrent) Encode() ([]byte, error) + func (t *Torrent) GetInfoHashHex() string + func (t *Torrent) GetPieceHashes() [][]byte + func (t *Torrent) GetTotalSize() int64 + func (t *Torrent) HasCASInfo() bool + func (t *Torrent) SetCASInfo(cas *CASInfo) + func (t *Torrent) SetPieces(pieces []byte) + type TorrentFile struct + Length int64 + MD5Sum string + Path []string + type TorrentInfo struct + Files []TorrentFile + Length int64 + MD5Sum string + Name string + PieceLength int64 + Pieces []byte