A class with extension methods for use with Bencoding.
BencodingExtensions
01 Syntax
Microsoft.VisualBasic.Serialization.Bencoding.BencodingExtensions
02 Methods
| Name | Overloads | Summary |
|---|---|---|
| BDecode | 1 | Decode the current instance. |
| ToList | 1 | cast object to a object array |
| ToBEncodeString | 1 | Generates the bencoded equivalent of the element. |
| ToBEncode | 1 | bencode有4种数据类型:string,integer,list和dictionary。 string:字符是以这种方式编码的: <字符串长度>:<字符串>。 如,"hello":5:hello 2. |
| ToBEncodeString | 1 |
03 Members
BDecode(
String)Decode the current instance.
Parameters
| Name | Type | Description |
|---|---|---|
s | String | The current instance. |
Returns
The root elements of the decoded string.
ToList(BElement)
cast object to a object array
Parameters
| Name | Type | Description |
|---|---|---|
b | BElement | - |
ToBEncodeString``1(
``0, Func(Of Object, Object))Generates the bencoded equivalent of the element.
Type Parameters
| Name | Description |
|---|---|
T |
Parameters
| Name | Type | Description |
|---|---|---|
obj | ``0 | - |
ToBEncode(
Object, Func(Of Object, Object))bencode有4种数据类型:string,integer,list和dictionary。
string:字符是以这种方式编码的: <字符串长度>:<字符串>。 如,"hello":5:hello
- integer:整数是以这种方式编码的: i<整数>e。
如,1234:i1234e
- list:列表是以这种方式编码的: l[数据1][数据2][数据3][…]e。
如,["hello","world",1234]
- "hello"编码:5:hello
- "world"编码:5:world
- 1234编码:i1234e
- 最终编码:l5:hello5:worldi1234ee
- dictionary:字典是以这种方式编码的: d[key1][value1][key2][value2][…]e,其中key必须是string而且按照字母顺序排序。
如,{"name":"jisen","coin":"btc","balance":1000}
- "name":"jisen"编码:4:name5:jisen
- "coin":"btc"编码:4:coin3:btc
- "balance":1000编码:7:balancei1000e
- 最终编码,按key的字母排序:d7:balancei1000e4:coin3:btc4:name5:jisene
Parameters
| Name | Type | Description |
|---|---|---|
obj | Object | - |
digest | Func(Of Object, Object) | - |
ToBEncodeString(
T, Func(Of Object, Object))