Encode and decode functions for the BitTorrent Bencode format.