Results 1 to 4 of 4

Thread: Is there a 62-ary algorithm?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,297

    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?

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,746

    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.

  4. #4
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Is there a 62-ary algorithm?

    Quote Originally Posted by jmcilhinney View Post
    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
  •  



Click Here to Expand Forum to Full Width