Convert BASE64 string to BASE16 (HEX) string?

Hey, I'm trying to write a program to convert from a BASE64 string to a BASE16 (HEX) string.

Here is an example:

     BASE64:   Ba7+Kj3N
HEXADECIMAL:   05 ae fe 2a 3d cd
     BINARY:   00000101 10101110 11111110 00101010 00111101 11001101
    DECIMAL:   5 174 254 42 61 205

What logic to convert from BASE64 to HEXIDECIMAL?
Why is the decimal notation broken?
Why is the binary representation broken into 6 sections?

I just want math, code that I can process, only this process confuses me. Thank:)

+5
source share
2 answers

Here is a function that will convert between any two databases: https://sites.google.com/site/computersciencesourcecode/conversion-algorithms/base-to-base


Edit (Hope this is completely clear ...)

Base 64.

, 64, , I, , :

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/

"A" 0, "B" - 1, "C" - 2,... "8" - 60, "9" - 61, + '- 62, '/'- 63. , , , 10 , ' 0 ', 0 ..

Soju , 64- 6 . 64, 64 , :

B        a        7        +        K        j        3        N
000001   011010   111011   111110   001010   100011   110111   001101

( , ):

000001011010111011111110001010100011110111001101

, , :

0000  0101  1010  1110  1111  1110  0010  1010  0011  1101  1100  1101

, 16:

0000  0101  1010  1110  1111  1110  0010  1010  0011  1101  1100  1101
0     5     A     E     F     E     2     A     3     D     C     D
+8

-64 (2 ^ 6) , , 2 64 ...

2 64 (2 ^ 12), 3 2 ^ 4 ...

(00)(01)(02)(03)(04)(05)---(06)(07)(08)(09)(10)(11) (base-64) maps directly to:

(00)(01)(02)(03)---(04)(05)(06)(07)---(08)(09)(10)(11) (base 16)

... 4 ... , ( char ):

  • -64-
  • - 64
  • - 64
  • 64 .

, . ... , , .

0

All Articles