How to return a string generated from a sha1 bytearray to that bytearray?

后端 未结 2 611
逝去的感伤
逝去的感伤 2021-01-23 19:05

first of all sorry for the bad English.

Well, I want to read the pieces hashes information from a torrent file. Currently, I\'m using https://github.com/hyPiRion/java-be

相关标签:
2条回答
  • 2021-01-23 19:15

    I'm storing binary data as strings, because the BEncode format in .torrent files, store that binary data as string

    Bencode "strings" are sequences of bytes, not sequences of unicode codepoints. Therefore a language's representation of bytes - byte[] or ByteBuffer in java - is appropriate and should only be interpreted as utf8 string in certain cases when they actually contain things that are supposed to be human-readable.

    So you should use a bencoding library that supports extraction of the raw bytes.

    0 讨论(0)
  • 2021-01-23 19:19

    Thanks guys for your answer, but I can find the solution using this https://github.com/bedeho/bencodej

    The lib loads the Bencode data alwais as bytearray with custom classes, and is able have a 1:1 with the bytestrings :p Thanks for all.

    0 讨论(0)
提交回复
热议问题