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

后端 未结 2 610
逝去的感伤
逝去的感伤 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.

提交回复
热议问题