-
May 7th, 2021, 12:59 AM
#1
Thread Starter
PowerPoster
Is there a 62-ary algorithm?
Is there a 62-ary algorithm:
0-9,a-z,A-Z
0azAz represents a decimal
Then how to convert between decimal and 62
-
May 7th, 2021, 01:06 AM
#2
Re: Is there a 62-ary algorithm?
Base-64 is a common way to represent binary data as text, because every digit represents 8 bytes. Presumably you could do any base below that simply by dropping the last two digits from the vase-64 set, whatever they happen to be. Never heard of anyone wanting to represent data in base-62 but I guess there's a case for everything. Converting between two numerical bases is a mathematical operation, so it's not really a coding problem until you know what the algorithm is and you're trying to implement it. I was taught how to do it in primary school, as I imagine most people are. I can't recall the specific details off the top of my head. I think that it is dividing by the base and creating a digit from the remainder but it would be quite easy to find out with a web search. It's then up to you how you implement that algorithm in your language of choice. Seems like you're asking for the logic first and then how to write code to implement the logic too. Which part are you doing?
-
May 7th, 2021, 01:51 AM
#3
Thread Starter
PowerPoster
Re: Is there a 62-ary algorithm?
I was also asked by a friend, maybe it is used for encryption algorithm. So sometimes we need a universal hexadecimal conversion code, or code conversion function. The general conversion function will be less efficient, but very convenient.
-
May 7th, 2021, 09:14 AM
#4
Re: Is there a 62-ary algorithm?
Originally Posted by jmcilhinney
Base-64 is a common way to represent binary data as text, because every digit represents 8 bytes.
Erm, ... please make that "6 Bits" instead of "8 Bytes" ...
(in case you were talking about the resulting Base64-String after a Base64-Encoding of a ByteArray).
An encoded Base64-String is 33.3333% longer than the original ByteStream.
The math behind that factor is:
- based on the used Bits per Alphabet-Member: 8 / 6 = 1.3333333333
- based on the amount of Alphabet-Members: Log(256) / Log(64) = 1.3333333333
Olaf
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|