Base64

By | May 1, 2021
Share the joy
  •  
  •  
  •  
  •  
  •  
  •  

959, in Base64 is O/. / is not uri-safe. An althernative is transform it to ASCII %47%.
But this lengthens the URL.
So in Base64,
+ ->
/ -> _

Or use Base62. But Base62 transformation is too complex.

In Base64, each char takes up 6 bits. So always make the coding 24 bits, or 3 bytes的整数. If not enough, use = as padding

base64_padding1

base64_padding2

https://code.tutsplus.com/tutorials/base-what-a-practical-introduction-to-base-encoding–net-27590

https://en.wikipedia.org/wiki/Base64#Decoding_Base64_with_padding