Convert byte array into any base

前端 未结 9 2447
梦如初夏
梦如初夏 2021-02-13 17:58

I have an array of bytes (any length), and I want to encode this array into string using my own base encoder. In .NET is standard Base64 encoder, but w

9条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-13 18:17

    If performance is not an issue, use the BigInteger class in the background. You have a constructor for BigInteger that takes byte array, and you can then manually run loops of division and modulus to get the representation in other non-standard bases.

    Also take a look at this.

提交回复
热议问题