Tool for coding with Base45 encoding, using 45 ASCII characters, which has become known since its use in the European green pass/certificate.

Base45 Encoding - dCode

Tag(s) : Character Encoding

dCode is free and its tools are a valuable help in games, maths, geocaching, puzzles and problems to solve every day!

A suggestion ? a feedback ? a bug ? an idea ? *Write to dCode*!

The Base45 encoding consists in writing the data in base 45 and using the following list of symbols `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:` Which corresponds to the 45 characters that can be used in a QR-code in alphanumeric mode so the correspondance table

Index | Character Base45 |
---|---|

0 | 0 |

1 | 1 |

2 | 2 |

3 | 3 |

4 | 4 |

5 | 5 |

6 | 6 |

7 | 7 |

8 | 8 |

9 | 9 |

10 | A |

11 | B |

12 | C |

13 | D |

14 | E |

15 | F |

16 | G |

17 | H |

18 | I |

19 | J |

20 | K |

21 | L |

22 | M |

23 | N |

24 | O |

25 | P |

26 | Q |

27 | R |

28 | S |

29 | T |

30 | U |

31 | V |

32 | W |

33 | X |

34 | Y |

35 | Z |

36 | |

37 | $ |

38 | % |

39 | * |

40 | + |

41 | - |

42 | . |

43 | / |

44 | : |

Encoding begins by cutting the data to be encoded from left to right in groups of 2 bytes. If the data has an odd number of bytes, the last group is 1 byte in size.

__Example:__ Encode the 3 characters `B45`, of ASCII code `[66,52,53]`, which are then split `[66,52],[53]`

Each pair of 2 bytes $ [a, b] $ is interpreted as a number in base $ 256 $ such that $ n = (a \times 256) + b $ (in base 10) which can then be converted into base 45 via a triple $ [c,d,e] $ such that $ n = c + (d \times 45) + (e \times 45^2) $. The characters in the correspondence table for the values '[c, d, e]' are noted (in that order) as encoded text.

Any last single byte $ a $ at the end of the data is also interpreted as a number in base 256 and converted to a pair $ [b,c] $ such that $ a = b + (45 \times c) $. The characters in the correspondence table for the values `[b,c]` are noted (in that order) as encoded text.

__Example:__ The couple `[66,52]` corresponds to the number 66 * 256 + 52 = 16948 and 16948 = 28 + 16 * 45 + 8 * 45 ^ 2, so the triplet [28,16,8] that is equivalent to the characters `S,G,8` in base45

The remaining byte `[53]` is written in base 45 as follows: 53 = 1 * 45 + 8, either the pair [1,8] or the characters `1,8` in base45. The full encoding of `B45` in base45 is `SG881`

For any string written in Base45, start by converting the characters into numeric values (according to the correspondence table).

__Example:__ Decode `SG881`, or the values `[28,16,8,8,1]`

Divide the values into groups of 3, from left to right. If the last group of 3 is not complete, add zeros `0` at the end.

__Example:__ `[28,16,8,8,1]` splits as `[28,16,8],[8,1,0]`

Interpret each group `[c,d,e]` as a number in base 45 as follows: $ n = c + (d \times 45) + (e \times 45^2) $ and note the values $ n $ obtained

__Example:__ `[28,16,8],[8,1,0]` is converted to `[16948],[53]`

Convert each number to base 256 (so in bytes)

__Example:__ 16948 = 66 * 256 + 52 or `[66,52]` and 53 remains `[53]` in base 256

The decoded message is the set of bytes. It can be interpreted in ASCII code (or Unicode)

__Example:__ `[66,52,53]` for the 3 ASCII characters `B,4,5` (plaintext)

Base-45 uses the 36 uppercase alphanumeric characters `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ` completed with the characters ` ` (space)', `$` (dollar), `%` (percent), `*` (asterisk), `+` (plus), `-` (minus/dash), `.` (period), `/` (slash) and `:` (colon).

Base-45 is optimized to transmit data with the alphanumeric mode of QR-codes.

It has been used in COVID-19 vaccines certificates and European Union green passes.

dCode retains ownership of the "Base45 Encoding" source code. Except explicit open source licence (indicated Creative Commons / free), the "Base45 Encoding" algorithm, the applet or snippet (converter, solver, encryption / decryption, encoding / decoding, ciphering / deciphering, breaker, translator), or the "Base45 Encoding" functions (calculate, convert, solve, decrypt / encrypt, decipher / cipher, decode / encode, translate) written in any informatic language (Python, Java, PHP, C#, Javascript, Matlab, etc.) and all data download, script, or API access for "Base45 Encoding" are not public, same for offline use on PC, mobile, tablet, iPhone or Android app!

Reminder : dCode is free to use.

The copy-paste of the page "Base45 Encoding" or any of its results, is allowed (even for commercial purposes) as long as you cite dCode!

Exporting results as a .csv or .txt file is free by clicking on the *export* icon

Cite as source (bibliography):

*Base45 Encoding* on dCode.fr [online website], retrieved on 2023-05-31,

base45,base,45,b45,encoding,code,qr,pass,covid,european

https://www.dcode.fr/base45-encoding

© 2023 dCode — The ultimate 'toolkit' to solve every games / riddles / geocaching / CTF.

Feedback