Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/interlab/p6-bencoder
Encode and Decode Bencoding data
https://github.com/interlab/p6-bencoder
bencode perl6 raku
Last synced: 17 days ago
JSON representation
Encode and Decode Bencoding data
- Host: GitHub
- URL: https://github.com/interlab/p6-bencoder
- Owner: interlab
- License: artistic-2.0
- Created: 2019-09-15T12:39:43.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-15T13:22:19.000Z (over 5 years ago)
- Last Synced: 2024-11-05T18:56:46.595Z (2 months ago)
- Topics: bencode, perl6, raku
- Language: Perl 6
- Homepage:
- Size: 166 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Bencoder
Encode and decode bencoding data (torrent files) lib for Perl 6## Install
`zef -v install https://github.com/interlab/p6-Bencoder.git`## Examples
### Encode data
```perl6
use Bencoder;
my $bdata = bencode({bar => 'spam', foo => 42}, True);
say $bdata; # d3:bar4:spam3:fooi42ee
```### Encode torrent file
```perl6
use Bencoder;
my $path = 'F:\examples\ubuntu-19.04-desktop-amd64.iso.torrent';
my $new-path = 'F:\examples\ubuntu-19.04-copy.torrent';
my %data = bdecode-file $path;
say %data.decode; # http://torrent.ubuntu.com:6969/announce
bencode-file($new-path, %data); # Dump file to new path
```### Decode data
```perl6
use Bencoder;
my $data = bdecode('13:Hello, World!', True);
say $data; # Hello, World!
```### Decode torrent file
```perl6
use Bencoder;
my $path = 'F:\examples\ubuntu-19.04-desktop-amd64.iso.torrent'; # Change your path
my %data = bdecode-file $path;
say %data.decode; # http://torrent.ubuntu.com:6969/announce
```### Get info-hash of torrent file
```perl6
use Bencoder::TorrentInfo;
my $tor-info = Bencoder::TorrentInfo.new(path => 'ubuntu-19.04-desktop-amd64.iso.torrent'); # Change your path
say $tor-info.info-hash; # D540FC48EB12F2833163EED6421D449DD8F1CE1F
```