Click here to Skip to main content
15,797,961 members
Please Sign up or sign in to vote.
4.00/5 (4 votes)

Does anyone have code for converting from base 64 to base 36 and back?

base 64 character set is 0123456789ABCDEF
base 36 character set is 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

This is needed as I can't represent the data I'm trying to display in the room I have to display it, it has to be displayed encrypted, but readable and using base 36 over base 64 dramatically reduces the length of the data.

1 solution

Base 64 is not restricted to the hex digits - it includes upper and lower case A-Z 0-9 and (normally) '+' and '/'
Base 64 is a superset of base 36, which includes only upper case A-Z 0-9

I think you are confused between Hexadecimal and base 64. Check your implementation.

Using Base 36 to represent Base 64 will not "reduce the length of the data" - if anything it will increase it, because many Base 64 characters will require two character spaces in Base 36
Share this answer
Stephen Hewison 26-Jun-12 11:11am    
You're correct. The question should say Hex digits. I have an encrypted byte array which I need to be presentable as readable characters. The powers who be are not happy with the base 64 character set and want just numbers and upper case letters.
Stephen Hewison 26-Jun-12 11:15am    
The main issue I have is the integer representation of the byte data is too big for a long and I can't use the BigInteger in the later frameworks as target devices are restricted to .Net 2. I think I may just break the byte array down into chunks which fit into a long.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900