{"id":18410653,"url":"https://github.com/vfk/swiftybencode","last_synced_at":"2025-07-08T22:03:54.286Z","repository":{"id":77516508,"uuid":"80629553","full_name":"VFK/SwiftyBencode","owner":"VFK","description":"A general purpose bencode decoder written in Swift 3","archived":false,"fork":false,"pushed_at":"2017-02-05T17:32:13.000Z","size":14,"stargazers_count":9,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-08T22:03:09.237Z","etag":null,"topics":["bencode","swift","swift-3","swift-library","swift-package-manager","torrent"],"latest_commit_sha":null,"homepage":null,"language":"Swift","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/VFK.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":"2017-02-01T14:48:20.000Z","updated_at":"2024-09-12T08:17:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"889d7816-650b-48d6-b578-c6ca04ccfdb6","html_url":"https://github.com/VFK/SwiftyBencode","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/VFK/SwiftyBencode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VFK%2FSwiftyBencode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VFK%2FSwiftyBencode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VFK%2FSwiftyBencode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VFK%2FSwiftyBencode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VFK","download_url":"https://codeload.github.com/VFK/SwiftyBencode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VFK%2FSwiftyBencode/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264357293,"owners_count":23595575,"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","swift","swift-3","swift-library","swift-package-manager","torrent"],"created_at":"2024-11-06T03:33:13.632Z","updated_at":"2025-07-08T22:03:54.266Z","avatar_url":"https://github.com/VFK.png","language":"Swift","readme":"# SwiftyBencode [![GitHub release](https://img.shields.io/github/release/VFK/SwiftyBencode.svg)](https://github.com/VFK/SwiftyBencode/releases) [![Build Status](https://travis-ci.org/VFK/SwiftyBencode.svg?branch=master)](https://travis-ci.org/VFK/SwiftyBencode)\n\n\u003e A general purpose [bencode](https://en.wikipedia.org/wiki/Bencode) decoder written in Swift 3\n\n## Usage\n```swift\nBencode.decode(data: Data) throws -\u003e BencodeResult\n```\n### BencodeResult\n```swift\nBencodeResult.integer -\u003e Int?\nBencodeResult.string -\u003e String?\nBencodeResult.list -\u003e [BencodeResult]?\nBencodeResult.dictionary -\u003e [String: BencodeResult]?\n\n// hexadecimal representation of swift Data.\nBencodeResult.hexString -\u003e String? // Data(bytes: [0, 1, 127, 128, 255]) -\u003e 00017f80ff\n```\n\n### Decoding torrent file\n```swift\nimport Bencode\n\nlet url: URL = \u003cpath to torrent file\u003e\nlet data = try! Data(contentsOf: url!)\n\ndo {\n  let result = try Bencode.decode(data: data)\n\n  if let announce = result.dictionary?[\"announce\"]?.string {\n    print(announce)\n  }\n\n  if let announceList = result.dictionary?[\"announce\"]?.list {\n    // announceList is [BencodeResult]\n    for item in announceList {\n      print(item.string!)\n    }\n  }\n\n  if let creationDate = result.dictionary?[\"creation date\"]?.integer {\n    print(creationDate)\n  }\n\n} catch BencodeDecodeError.invalidFormat {\n\n} catch {\n\n}\n```\n\n## Installation\n### Swift Package Manager\n\n```swift\nimport PackageDescription\n\nlet package = Package(\n  \u003c...\u003e\n  dependencies: [\n    .Package(url: \"https://github.com/VFK/SwiftyBencode.git\", majorVersion: 0, minor: 2)\n  ]\n  \u003c...\u003e\n)\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvfk%2Fswiftybencode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvfk%2Fswiftybencode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvfk%2Fswiftybencode/lists"}