BasE91
Base91, stylized as basE91, is a form of binary-to-text encoding scheme developed by Joachim Henke[1]. It divides the binary data stream into 13-bit packets which are then encoded in 2 ASCII characters[2]. Assuming eight bits per ASCII character, on average the encoded size will be ³⁄₁₆ larger than the original. That is more efficient than the ¹⁄₃ increase of base64 (which uses four characters to represent three bytes of data) and ¹⁄₄ increase of base85 (which uses five characters to represent four bytes of data).
Basic idea[edit]
Among the 94 printable ASCII characters (0x21-0x7E), basE91 excludes the following three characters
-
(dash, 0x2D)\
(backslash, 0x5C)'
(apostrophe, 0x27)
Two radix-91 digits provide 912 = 8,281 possible values which is enough to provide 213 = 8,192 possible values that a 13-bit data value can represent. When encoding, each group of 13 bits is converted into 2 radix-91 digits. Then each digit will be encoded as an ASCII printable character using the below table.
Value | Char | Value | Char | Value | Char | Value | Char | Value | Char | Value | Char | Value | Char | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | A
|
13 | N
|
26 | a
|
39 | n
|
52 | 0
|
65 | %
|
78 | >
| ||||||
1 | B
|
14 | O
|
27 | b
|
40 | o
|
53 | 1
|
66 | &
|
79 | ?
| ||||||
2 | C
|
15 | P
|
28 | c
|
41 | p
|
54 | 2
|
67 | (
|
80 | @
| ||||||
3 | D
|
16 | Q
|
29 | d
|
42 | q
|
55 | 3
|
68 | )
|
81 | [
| ||||||
4 | E
|
17 | R
|
30 | e
|
43 | r
|
56 | 4
|
69 | *
|
82 | ]
| ||||||
5 | F
|
18 | S
|
31 | f
|
44 | s
|
57 | 5
|
70 | +
|
83 | ^
| ||||||
6 | G
|
19 | T
|
32 | g
|
45 | t
|
58 | 6
|
71 | ,
|
84 | _
| ||||||
7 | H
|
20 | U
|
33 | h
|
46 | u
|
59 | 7
|
72 | .
|
85 | `
| ||||||
8 | I
|
21 | V
|
34 | i
|
47 | v
|
60 | 8
|
73 | /
|
86 | {
| ||||||
9 | J
|
22 | W
|
35 | j
|
48 | w
|
61 | 9
|
74 | :
|
87 | |
| ||||||
10 | K
|
23 | X
|
36 | k
|
49 | x
|
62 | !
|
75 | ;
|
88 | }
| ||||||
11 | L
|
24 | Y
|
37 | l
|
50 | y
|
63 | #
|
76 | <
|
89 | ~
| ||||||
12 | M
|
25 | Z
|
38 | m
|
51 | z
|
64 | $
|
77 | =
|
90 | "
|
Advantages:[edit]
- Conversion is fast compared to base85
- Because only 13-bit math is used, it'll be more suitable for 16-bit embedded systems than base85, which requires at least 32-bit math.
- The small size of the packet makes the use of a lookup table is possible, eliminating the need for a division/multiplication when encoding/decoding. If implemented that way, base85 would require a 232 lookup table of 5 bytes which needs at least 5GiB of memory.
- The overhead is just 23% compared to base64, down to 14% in case of 0-byte blocks[1]
- Easy to quote in many programming languages because backslash and single quote are not used
Disadvantages[edit]
- Slower encode/decode compared to base64
- Cannot be easily used in double-quoted strings without escape characters or raw string, due to the use of
$
and"
in the digit alphabet
Example for basE91[edit]
A quote from Thomas Hobbes's Leviathan:
- Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.
If this is initially encoded using US-ASCII, it can be re-encoded in basE91 as follows:
8D$J`/wC4!c.hQ;mT8,<p/&Y/H@$]xlL3oDg<W.0$FW6GFMo_D8=8=}AMf][|LfVd/<P1o/1Z2(.I+LR6tQQ0o1a/2/WtN3$3t[x&k)zgZ5=p;LRe.{B[pqa(I.WRT%yxtB92oZB,2,Wzv;Rr#N.cju"JFXiZBMf<WMC&$@+e95p)z01_*UCxT0t88Km=UQJ;WH[#F]4pE>i3o(g7=$e7R2u>xjLxoefB.6Yy#~uex8jEU_1e,MIr%!&=EHnLBn2h>M+;Rl3qxcL5)Wfc,HT$F]4pEsofrFK;W&eh#=#},|iKB,2,W]@fVlx,a<m;i=CY<=Hb%}+},F
See also[edit]
- Base32
- Base36
- base58
- Base64
- Base85
- Binary-to-text encoding for a comparison of various encoding algorithms
- PostScript Standard Encoding
References[edit]
- ↑ 1.0 1.1 "basE91 - binary to ASCII text encoding". base91.sourceforge.net. Retrieved 2018-04-08.
- ↑ "Base91 Encoding Cipher - Decoder, Encoder, Solver, Translator". www.dcode.fr. Retrieved 2018-04-08.
External links[edit]
- https://github.com/bwaldvogel/base91
- https://github.com/aberaud/base91-python
- https://github.com/bproctor/base91
References[edit]
This article "BasE91" is from Wikipedia. The list of its authors can be seen in its historical and/or the page Edithistory:BasE91. Articles copied from Draft Namespace on Wikipedia could be seen on the Draft Namespace of Wikipedia and not main one.