{"id":18619943,"url":"https://github.com/xtyxtyx/bencode","last_synced_at":"2025-04-11T02:30:54.963Z","repository":{"id":59150053,"uuid":"198246627","full_name":"xtyxtyx/bencode","owner":"xtyxtyx","description":"This library provides classes to encode/decode bencoded bytes. Mainly used to implement bittorrent related functions.","archived":false,"fork":false,"pushed_at":"2019-07-22T15:14:15.000Z","size":30,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T22:44:33.873Z","etag":null,"topics":["bencode","decode","encode","torrent"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/torrent_bencode","language":"Dart","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/xtyxtyx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-22T15:03:08.000Z","updated_at":"2025-02-23T15:54:18.000Z","dependencies_parsed_at":"2022-09-13T10:50:14.942Z","dependency_job_id":null,"html_url":"https://github.com/xtyxtyx/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/xtyxtyx%2Fbencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtyxtyx%2Fbencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtyxtyx%2Fbencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xtyxtyx%2Fbencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xtyxtyx","download_url":"https://codeload.github.com/xtyxtyx/bencode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248329527,"owners_count":21085550,"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":["bencode","decode","encode","torrent"],"created_at":"2024-11-07T04:04:16.047Z","updated_at":"2025-04-11T02:30:54.700Z","avatar_url":"https://github.com/xtyxtyx.png","language":"Dart","readme":"This library provides classes to encode/decode bencoded bytes.\nMainly used to implement bittorrent related functions.\n\n\n## Features\n\n- Decode/encode bencoded bytes.\n\n## Usage\n\nExample:\n\n```dart\nimport 'dart:typed_data';\nimport 'package:bencode/bencode.dart';\n\nmain() async {\n  var decoded = bDecoder.convertString('d5:hello5:worlde');\n  // or final decoded = bDecoder.convert('d5:hello5:worlde'.runes.toString());\n  print(decoded);\n  // Output: {hello: world}\n  print(decoded is Map);\n  // Output: true\n\n  decoded = bDecoder.convertString('i123e');\n  print(decoded);\n  // Output: 123\n  print(decoded is int);\n  // Output: true\n\n  decoded = bDecoder.convertString('li123ei123ee');\n  print(decoded);\n  // Output: [123, 123]\n  print(decoded is List);\n  // Output: true\n\n  decoded = bDecoder.convertString('11:hello world');\n  print(decoded);\n  // bencoded strings are converted to bytes by default.\n  // Output: [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]\n  print(String.fromCharCodes(decoded));\n  // Output: hello world\n  print(decoded is List\u003cint\u003e);\n  // Output: true\n\n  var encoded = bEncoder.convert({'hello': 'world'});\n  print(encoded);\n  // Output: [100, 53, 58, 104, 101, 108, 108, 111, 53, 58, 119, 111, 114, 108, 100, 101]\n  print(String.fromCharCodes(encoded));\n  // Output: d5:hello5:worlde\n\n  encoded = bEncoder.convert(123);\n  print(String.fromCharCodes(encoded));\n  // Output: i123e\n\n  encoded = bEncoder.convert([123, 456]);\n  print(String.fromCharCodes(encoded));\n  // Output: li123ei456ee\n\n  encoded = bEncoder.convert(Uint8List.fromList([123, 123]));\n  print(encoded);\n  // Output: [50, 58, 123, 123]\n  print(String.fromCharCodes(encoded));\n  // Output: 2:{{\n}\n\n```\n\nDecode bittorrent files:\n```dart\nimport 'dart:io';\nimport 'package:bencode/bencode.dart';\n\nmain() async {\n  final data = File('test/multi.torrent').readAsBytesSync();\n  final decoded = bDecoder.convert(data);\n  print(decoded.keys);\n  // Output: (announce, announce-list, created by, creation date, encoding, info)\n}\n```\n\n## Tests\n\nRun tests:\n```\npub run test\n```\n\n## Features and bugs\n\nPlease file feature requests and bugs at the [issue tracker][tracker].\n\n[tracker]: http://github.com/xtyxtyx/bencode/issues\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtyxtyx%2Fbencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxtyxtyx%2Fbencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxtyxtyx%2Fbencode/lists"}