@@ -23,7 +23,6 @@ const _base64EncodingRfc4648 = [
23
23
0x77 , 0x78 , 0x79 , 0x7a , 0x30 , 0x31 , 0x32 , 0x33 ,
24
24
0x34 , 0x35 , 0x36 , 0x37 , 0x38 , 0x39 , 0x2b , 0x2f ,
25
25
];
26
-
27
26
const _base64EncodingRfc4648UrlSafe = [
28
27
0x41 , 0x42 , 0x43 , 0x44 , 0x45 , 0x46 , 0x47 , 0x48 , //
29
28
0x49 , 0x4a , 0x4b , 0x4c , 0x4d , 0x4e , 0x4f , 0x50 ,
@@ -34,7 +33,6 @@ const _base64EncodingRfc4648UrlSafe = [
34
33
0x77 , 0x78 , 0x79 , 0x7a , 0x30 , 0x31 , 0x32 , 0x33 ,
35
34
0x34 , 0x35 , 0x36 , 0x37 , 0x38 , 0x39 , 0x2d , 0x5f ,
36
35
];
37
-
38
36
const _base64DecodingRfc4648 = [
39
37
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, //
40
38
__, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
@@ -45,6 +43,26 @@ const _base64DecodingRfc4648 = [
45
43
43 , 44 , 45 , 46 , 47 , 48 , 49 , 50 , 51 , __, __, __, __, __, __, __, __, __, __,
46
44
];
47
45
46
+ const _base64EncodingBcrypt = [
47
+ 0x2e , 0x2f , 0x41 , 0x42 , 0x43 , 0x44 , 0x45 , 0x46 , //
48
+ 0x47 , 0x48 , 0x49 , 0x4a , 0x4b , 0x4c , 0x4d , 0x4e ,
49
+ 0x4f , 0x50 , 0x51 , 0x52 , 0x53 , 0x54 , 0x55 , 0x56 ,
50
+ 0x57 , 0x58 , 0x59 , 0x5a , 0x61 , 0x62 , 0x63 , 0x64 ,
51
+ 0x65 , 0x66 , 0x67 , 0x68 , 0x69 , 0x6a , 0x6b , 0x6c ,
52
+ 0x6d , 0x6e , 0x6f , 0x70 , 0x71 , 0x72 , 0x73 , 0x74 ,
53
+ 0x75 , 0x76 , 0x77 , 0x78 , 0x79 , 0x7a , 0x30 , 0x31 ,
54
+ 0x32 , 0x33 , 0x34 , 0x35 , 0x36 , 0x37 , 0x38 , 0x39 ,
55
+ ];
56
+ const _base64DecodingBcrypt = [
57
+ __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, //
58
+ __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __, __,
59
+ __, __, __, __, __, __, __, __, 00 , 01 , 54 , 55 , 56 , 57 , 58 , 59 , 60 , 61 , 62 ,
60
+ 63 , __, __, __, __, __, __, __, 02 , 03 , 04 , 05 , 06 , 07 , 08 , 09 , 10 , 11 , 12 ,
61
+ 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 26 , 27 , __, __, __, __,
62
+ __, __, 28 , 29 , 30 , 31 , 32 , 33 , 34 , 35 , 36 , 37 , 38 , 39 , 40 , 41 , 42 , 43 , 44 ,
63
+ 45 , 46 , 47 , 48 , 49 , 50 , 51 , 52 , 53 , __, __, __, __, __, __, __, __, __, __,
64
+ ];
65
+
48
66
// ========================================================
49
67
// Base-64 Codec
50
68
// ========================================================
@@ -142,4 +160,23 @@ class Base64Codec extends HashlibCodec {
142
160
alphabet: _base64DecodingRfc4648,
143
161
),
144
162
);
163
+
164
+ /// Codec instance to encode and decode 8-bit integer sequence to 6-bit
165
+ /// Base-64 character sequence using the alphabet described in
166
+ /// [Bcrypt] (https://en.wikipedia.org/wiki/Bcrypt#base64_encoding_alphabet):
167
+ /// ```
168
+ /// ./ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
169
+ /// ```
170
+ ///
171
+ /// It is not padded.
172
+ static const Base64Codec bcrypt = Base64Codec ._(
173
+ encoder: AlphabetEncoder (
174
+ bits: 6 ,
175
+ alphabet: _base64EncodingBcrypt,
176
+ ),
177
+ decoder: AlphabetDecoder (
178
+ bits: 6 ,
179
+ alphabet: _base64DecodingBcrypt,
180
+ ),
181
+ );
145
182
}
0 commit comments