{"id":15684427,"url":"https://github.com/ybubnov/libbencode","last_synced_at":"2026-03-05T11:04:14.049Z","repository":{"id":78009278,"uuid":"51704004","full_name":"ybubnov/libbencode","owner":"ybubnov","description":"The Bencode library is a template-based implementation of the data serialization into the Bencode format.","archived":false,"fork":false,"pushed_at":"2017-08-07T12:08:48.000Z","size":70,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-01T08:38:52.030Z","etag":null,"topics":["bencode","cpp11","torrent"],"latest_commit_sha":null,"homepage":"","language":"C++","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/ybubnov.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-14T17:09:06.000Z","updated_at":"2025-02-27T10:30:14.000Z","dependencies_parsed_at":"2023-03-12T03:24:20.628Z","dependency_job_id":null,"html_url":"https://github.com/ybubnov/libbencode","commit_stats":{"total_commits":44,"total_committers":3,"mean_commits":"14.666666666666666","dds":0.4545454545454546,"last_synced_commit":"10038ea7b337f63092d79167227085836b7a58a0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ybubnov/libbencode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybubnov%2Flibbencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybubnov%2Flibbencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybubnov%2Flibbencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybubnov%2Flibbencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ybubnov","download_url":"https://codeload.github.com/ybubnov/libbencode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ybubnov%2Flibbencode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30121090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T10:44:24.758Z","status":"ssl_error","status_checked_at":"2026-03-05T10:44:15.079Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","cpp11","torrent"],"created_at":"2024-10-03T17:16:32.595Z","updated_at":"2026-03-05T11:04:09.038Z","avatar_url":"https://github.com/ybubnov.png","language":"C++","readme":"# libbencode - The Bencode coding library\n\n[![Build Status][BuildStatus]](https://travis-ci.org/ybubnov/libbencode)\n\nThe Bencode library is an elementary template-based implementation of the data serialization into the Bencode format. The Bencode format is commonly used in the [BitTorrent](https://wiki.theory.org/BitTorrentSpecification) protocol to encode the metadata of torrents.\n\n## Installation\n\nThe build mechanism of the library is based on the [CMake](https://cmake.org) tool. It could be either compiled from sources or installed from the distribution repository (e.g. for debian-based systems):\n```bash\n$ sudo apt-get install cmake\n```\n\nTo keep the source tree clean, it would be good to create a separate folder were all compiled binaries and generated makefiles will reside:\n```bash\n$ mkdir build\n```\n\nAs the directory created, all required build scripts will be generated inside by executing the following commands:\n```bash\n$ cd build\n$ cmake ..\n```\n\nAfter successful scripts generation, the library could be compiled and optionally tested.\n```bash\n$ make\n$ make test\n```\n\nBy default library will be installed into the ```/usr/local``` directory. The destination path could be changed by specifying the ```-DCMAKE_INSTALL_PREFIX``` attribute on the step of makefile generation:\n```bash\n$ cmake -DCMAKE_INSTALL_PREFIX=/usr ..\n```\n\nThe library consits only of the headers file, therefore the installation does not require any source code compilation:\n```\n$ make install\n```\n\nOptionally, the destination path could be overridden with ```DESTDIR``` environment variable:\n```\n$ make DESTDIR=/opt install\n```\n\n## Usage\n\n### Examples\n\nThe usage is pretty straightforward. Here is an example of dictionary and a list creation:\n```cpp\n// Create an associative array of Bencode values.\nbencode::dict d;\n\nd[\"port wine\"] = bencode::make_integer(777);\nd[\"green\"] = bencode::make_string(\"elephant\");\n\n// Create a 2-elements list of Bencode values.\nbencode::list l(2);\n\nl[0] = bencode::make_string(\"worsening\");\nl[1] = bencode::make_string(\"retaliation\");\n```\n\n### Input-output stream\n\nThe library provides input and output classes derived from ```std::basic_istream``` and ```std::basic_ostream``` prespectively to perform the handfull values serialization.\n```cpp\n// Create a new Bencode output stream\nbencode::ostream os(std::cout.rdbuf());\n\n// Create a new Bencode value\nbencode::string s(\"a string\");\n\n// output: `8:a string`\nos \u003c\u003c s;\n```\n\n### User-defined operators\n\nTo create polimorphic shared pointers to the Bencode values, the syntax of string literals could be used:\n```cpp\n// Create a bencode string.\nauto s = \"6:string\"_bencode;\n\n// Create a bencode integer.\nauto i = \"i777e\"_bencode;\n\n// Create a bencode list.\nauto l = \"li1ei2ei3ee\"_bencode;\n\n// Create a bencode dictionary.\nauto d = \"d5:first:i1e6:second:i2ee\"_bencode;\n```\n\n## License\n\nThe Bencode library is distributed under MIT license, therefore you are free to do with code whatever you want. See the [LICENSE](LICENSE) file for full license text.\n\n[BuildStatus]:   https://travis-ci.org/ybubnov/libbencode.svg?branch=master\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybubnov%2Flibbencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fybubnov%2Flibbencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fybubnov%2Flibbencode/lists"}