Skip to content

Instantly share code, notes, and snippets.

@pom421
Created November 3, 2018 23:56
Show Gist options
  • Save pom421/8667e61d90bd61628a1198e79797aea8 to your computer and use it in GitHub Desktop.
Save pom421/8667e61d90bd61628a1198e79797aea8 to your computer and use it in GitHub Desktop.
Suppose we want to encode <toto, so :
< t o t o
60 116 111 116 111 // in decimal
00111100 01110100 01101111 01110100 01101111 // in binary
00111100 01110100 01101111 01110100 01101111 00000000 // add optionnal complement (00000000) to have a multiple of 24 bits
001111 000111 010001 101111 011101 000110 111100 000000 // group of 6 * 3 bits
P H R v d G 8 = // use of Base64 index (see below)
If we want to encode <toto>
< t o t o >
60 116 111 116 111 62 // in decimal
00111100 01110100 01101111 01110100 01101111 00111110 // in binary
001111 000111 010001 101111 011101 000110 111100 111110 // in groupe of 3 x 6 bits. There is no rest, so no complement to add
P H R v d G 8 +
Remark : the before last character is still a 8 because the character > is 00111110 in binary. So the first 2 bits are zeros and so it is still a 8 value.
--------
Base64 index :
Valeur Codage Valeur Codage Valeur Codage Valeur Codage
0 000000 A 17 010001 R 34 100010 i 51 110011 z
1 000001 B 18 010010 S 35 100011 j 52 110100 0
2 000010 C 19 010011 T 36 100100 k 53 110101 1
3 000011 D 20 010100 U 37 100101 l 54 110110 2
4 000100 E 21 010101 V 38 100110 m 55 110111 3
5 000101 F 22 010110 W 39 100111 n 56 111000 4
6 000110 G 23 010111 X 40 101000 o 57 111001 5
7 000111 H 24 011000 Y 41 101001 p 58 111010 6
8 001000 I 25 011001 Z 42 101010 q 59 111011 7
9 001001 J 26 011010 a 43 101011 r 60 111100 8
10 001010 K 27 011011 b 44 101100 s 61 111101 9
11 001011 L 28 011100 c 45 101101 t 62 111110 +
12 001100 M 29 011101 d 46 101110 u 63 111111 /
13 001101 N 30 011110 e 47 101111 v
14 001110 O 31 011111 f 48 110000 w (complément) =
15 001111 P 32 100000 g 49 110001 x
16 010000 Q 33 100001 h 50 110010 y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment