Skip to content

Nemesis-AS/bencode-parser-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bencode Parser

A bencode parser written in Rust

Getting Started

use bencode::{BEncode, Options};

let path: PathBuf = PathBuf::from("./examples/big-buck-bunny.torrent");
let bytes = fs::read(path).expect("Couldn't Read File!");
let options: Options = Options::default();
let res: BEncode = BEncode::parse(bytes, options);
println!("Decoded Object: {:?}", res);

What is [Binary String]?

The torrent files have a property called pieces where the SHA-1 hashes of all the pieces of the torrent are stored, which is in the form of a binary string and not UTF-8. Parsing it as a String would make the program unsafe as the String will not be checked before parsing. To prevent this, all the binary strings are used in the binary(Vec<u8>) for itself.

About

A bencode parser written in Rust

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages