简体   繁体   中英

Perform bitwise operations on Radix64 characters in Java

I have a string in Radix64 characters:

HR5nYD8xGrw

and I need to be able to perform bitwise operations on the bits in this string, but preserve the Radix64 encoding. For example, if I do a left shift, have it drop the overflow bit, and stay inside the character set of Radix64, not turn into some random ASCII character. Aside from manually converting them to binary and writing my own versions of all of the operators I would need, is there a way to do this?

You just convert them to plain numbers, apply the shift to them and convert back to "base64".

It's not different to applying bit operators to numbers written in base 10, you don't use the string, you use the number corrresponding to the string, and then print it back to a string.

9 << 1 == 18

but "9" and "18" are not really related as strings...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM