b_encode_decode 1.0.4 copy "b_encode_decode: ^1.0.4" to clipboard
b_encode_decode: ^1.0.4 copied to clipboard

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

example/b_encode_decode_example.dart

import 'dart:typed_data';

import 'package:b_encode_decode/b_encode_decode.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);
}
0
likes
160
points
187
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on b_encode_decode