Base conversion of arbitrary sized numbers (PHP)

前端 未结 3 570
天涯浪人
天涯浪人 2020-12-17 02:52

I have a long \"binary string\" like the output of PHPs pack function.

How can I convert this value to base62 (0-9a-zA-Z)? The built in maths functions overflow with

3条回答
  •  [愿得一人]
    2020-12-17 03:52

    Unless you really, really have to have base62, why not go for:

    base64_encode()
    base64_decode()
    

    The only other added characters are "+" and "=", and it's a very well-known method to pack and unpack binary strings with available functions in many other languages.

提交回复
热议问题