bencode_dart 1.0.2 copy "bencode_dart: ^1.0.2" to clipboard
bencode_dart: ^1.0.2 copied to clipboard

A Dart library for implementing the encoding and decoding of the Bencode format.

example/bencode_dart_example.dart

import 'dart:typed_data';

import 'package:bencode_dart/bencode_dart.dart' as bencode;

void main() {
  print(String.fromCharCodes(bencode.encode('string'))); // => "6:string"
  print(String.fromCharCodes(bencode.encode(123))); // => "i123e"
  print(
      String.fromCharCodes(bencode.encode(['str', 123]))); // => "l3:stri123ee"
  print(String.fromCharCodes(
      bencode.encode({'key': 'value'}))); // => "d3:key5:valuee"
  var map = bencode.decode(Uint8List.fromList('d3:key5:valuee'.codeUnits),
      stringEncoding:
          'utf-8'); // => { key: "value" } , the string value is bytes array

  print(map);
  // Special character
  var ccc = bencode.encode({'δΈ­ζ–‡': 'ddd'});
  var m1 = bencode.decode(ccc);
  print(m1);
}
3
likes
30
pub points
17%
popularity

Publisher

unverified uploader

A Dart library for implementing the encoding and decoding of the Bencode format.

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

More

Packages that depend on bencode_dart