-
Notifications
You must be signed in to change notification settings - Fork 16
/
base64_base32_hex_octal.format.txt
98 lines (90 loc) · 6.73 KB
/
base64_base32_hex_octal.format.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
BASE64 BASE32 HEX OCTAL
BASE64 STANDARDS ==> #Main ones:
# - standard: RFC 4648
# - base64url: RFC 4648
# - base58: https://datatracker.ietf.org/doc/html/draft-msporny-base58
# - MIME: RFC 2045
# - PEM: RFC 1421
#Variations:
# - OpenPGP: RFC 4880. Like MIME, without chars outside charset
# - ni://: RFC 6920. Like base64url, with no = padding
#"Standard" syntax allows (but does not recommend):
# - chars outside charset
# - optional padding
# - newlines at any fixed|max length
GOAL ==> #Encode binary <-> ASCII
BASE64 FORMAT ==> #1 byte (6 binary bits) <-> 1 character (8 bits)
# - among 64-charset:
# - A-Z a-z 0-9 + /
# - (base64url only) A-Z a-z 0-9 - _
# - (MIME) chars outside charset are allowed, but ignored
# - padding:
# - 0-bits if binary less than 6 bits
# - so encoding binary then decoding might append non-significant 0-bits
# - = at end if characters not multiple of 4
# - goal is to be able to decode without knowing total length
# - (base64url) can omit = if length known
# - (base64url) percent-encodes =
# - (MIME, PEM) newlines (CR+LF):
# - not significant
# - (MIME) added every 76 chars (max length)
# - (PEM) added every 64 chars (fixed length)
VARIANTS ==> #Base85:
# - 85-charset: ASCII from ! to u
# - also called ASCII85
#Base58:
# - 58-charset: like base64 but
# - no I O l 0 + /
# - no padding
#Base32:
# - 32-charset: A-Z 2-7
# - (extended hex variation) 0-9 A-V
# - = padding use groups of 8 characters
#Base16 (hex):
# - 16-charset: 0-9 A-F
# - no = padding
#Octal:
# - 8-charset: 0-7
# - no = padding
#Binary:
# - 2-charset: 0-1
# - no = padding
#Comparison:
# - base85: smallest payload
# - base64 (33% extra size): smaller payload
# - base58: no ambiguity (e.g. 0 and O). URL|path-friendly like base64url
# - base32 (60% extra size): all lowercase. No punctuation
# - hex (100% extra size): no ambiguity (e.g. 0 and O). Easier translation (1 byte === 2 chars)
# - octal (300% extra size): only numbers. Easy translation (1 byte === 4 chars)
# - binary (700% extra size): closer to machine representation
TOOLS ==> #Base64:
# - binary: base64 (GNU coreutils)
# - JavaScript: WINDOW.atob|btoa() (browser), BUFFER ENCOODING (Node.js), js-base64
# - SQL: encode|decode()
#Hex:
# - binary: od, hexdump, vim+xxd
# - Bash: 0x... \x...
# - JavaScript: 0x...
# - R: charToRaw|rawToChar(), \x...
# - C/C++: 0x... \x...
# - SQL: to_hex(), encode|decode()
#Octal:
# - binary: od, vim+xxd
# - Bash: 0... \...
# - JavaScript: 0o...
# - R: \...
# - C/C++: 0... \...
#Binary:
# - Bash: 2#...
# - JavaScript: 0b...
# - R: rawToBits|intToBits()
#Free radix:
# - Bash NUM#... (2-64)
# - JavaScript: NUM.toString() or parseInt() (2-36)
SECURITY ==> # - considering variations, must normalize before doing comparisons
# - allowing chars outside charset:
# - might trigger bugs in implementations (e.g. buffer overflow, wrong comparisons)
# - steganography
# - trailing non-significant 0-bits can be used for steganography