{"id":13414708,"url":"https://github.com/hexlab/bencode","last_synced_at":"2026-03-09T16:48:28.162Z","repository":{"id":149989753,"uuid":"226493005","full_name":"hexlab/bencode","owner":"hexlab","description":"Bencode is the encoding used by the p2p file sharing system BitTorrent","archived":false,"fork":false,"pushed_at":"2019-12-18T15:30:30.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-07-31T21:53:12.232Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hexlab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-12-07T10:27:03.000Z","updated_at":"2019-12-18T15:30:32.000Z","dependencies_parsed_at":"2023-04-15T16:04:38.029Z","dependency_job_id":null,"html_url":"https://github.com/hexlab/bencode","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexlab%2Fbencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexlab%2Fbencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexlab%2Fbencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hexlab%2Fbencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hexlab","download_url":"https://codeload.github.com/hexlab/bencode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243658054,"owners_count":20326459,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T21:00:33.527Z","updated_at":"2026-03-09T16:48:28.102Z","avatar_url":"https://github.com/hexlab.png","language":"Python","funding_links":[],"categories":["Protocols"],"sub_categories":["BitTorrent"],"readme":"# Bencode\n\nBencode is the encoding used by the p2p file sharing system BitTorrent.\n\n## Example\n```python\nfrom bencode import bencode, bdecode\nwith open('1.torrent', 'rb') as binary_file:\n    data = binary_file.read()\nres = bdecode(data)\nbytes_ = bencode(res)\n```\n\n## How to run tests\n\n```python tests.py```\n\n## Specs\n\n#### Byte strings\n\nEncoded as follows:\n\n    \u003cstring length encoded in base ten ASCII\u003e:\u003cstring data\u003e\n\nExamples:\n\n    3:foo represents the string \"foo\"\n    0: represents the empty string \"\"\n\n#### Integers\n\nIntegers are encoded as follows: \n\n    i\u003cinteger encoded in base ten ASCII\u003ee\n\nExamples:\n\n    i3e represents the integer \"3\"\n    i-3e represents the integer \"-3\"\n    i-0e is invalid. \n    i03e are invalid, but\n    i0e represents the integer \"0\".\n\n#### Lists\n\nLists are encoded as follows:\n\n    l\u003cbencoded values\u003ee\n\nThe initial **l** and trailing **e** are beginning and ending delimiters. \nLists may contain any bencoded type, including integers, strings, \ndictionaries, and even lists within other lists.\n\nRepresents\n\n    l3:foo3:bare represents the list of two strings: [\"foo\", \"bar\"]\n    le represents an empty list: []\n\n#### Dictionaries\n\nDictionaries are encoded as follows: \n\n    d\u003cbencoded string\u003e\u003cbencoded element\u003ee\n\nThe initial **d** and trailing **e** are the beginning and ending delimiters. \nNote that the keys must be bencoded strings. The values may be any\nbencoded type, including integers, strings, lists, and other\ndictionaries. Keys must be strings and appear in sorted order\n(sorted as raw strings, not alphanumerics). The strings should be\ncompared using a binary comparison, not a culture-specific \"natural\"\ncomparison.\n\nExamples:\n\n    d4:dead4:beef3:foo3:bare represents the dictionary {\"dead\": \"beef\", \"foo\": \"bar\"}\n    d3:fool1:a1:bee represents the dictionary {\"foo\": [\"a\", \"b\"]}\n    d9:publisher3:bob17:publisher-webpage15:www.example.com18:publisher.location4:homee represents {\"publisher\": \"bob\", \"publisher-webpage\": \"www.example.com\", \"publisher.location\": \"home\"}\n    de represents an empty dictionary {}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexlab%2Fbencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhexlab%2Fbencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhexlab%2Fbencode/lists"}