diff options
-rw-r--r-- | src/sledjchisl/sledjchisl.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/sledjchisl/sledjchisl.c b/src/sledjchisl/sledjchisl.c index 87aac15..cc11565 100644 --- a/src/sledjchisl/sledjchisl.c +++ b/src/sledjchisl/sledjchisl.c | |||
@@ -83,7 +83,7 @@ GLOBALS( | |||
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | // Duplicate some small amount of code from qLibc, coz / and = are not good choices, and the standard says we can pick those. | 86 | // Duplicate some small amount of code from qLibc, coz /, + and, = are not good choices, and the standard says we can pick those. |
87 | /** | 87 | /** |
88 | * Encode data using BASE64 algorithm. | 88 | * Encode data using BASE64 algorithm. |
89 | * | 89 | * |
@@ -118,8 +118,7 @@ char *qB64_encode(const void *bin, size_t size) { | |||
118 | 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', // 00-0F | 118 | 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', // 00-0F |
119 | 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', // 10-1F | 119 | 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', // 10-1F |
120 | 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', // 20-2F | 120 | 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', // 20-2F |
121 | // 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' // 30-3F | 121 | 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' // 30-3F |
122 | 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','_' // 30-3F | ||
123 | }; | 122 | }; |
124 | 123 | ||
125 | if (size == 0) { | 124 | if (size == 0) { |
@@ -151,15 +150,17 @@ char *qB64_encode(const void *bin, size_t size) { | |||
151 | (nIdxOfThree >= 1) ? | 150 | (nIdxOfThree >= 1) ? |
152 | B64CHARTBL[(((szIn[1] & 0x0F) << 2) | 151 | B64CHARTBL[(((szIn[1] & 0x0F) << 2) |
153 | | ((szIn[2] & 0xC0) >> 6))] : | 152 | | ((szIn[2] & 0xC0) >> 6))] : |
154 | // '='; | 153 | '='; |
155 | '-'; | 154 | *pszB64Pt++ = (nIdxOfThree >= 2) ? B64CHARTBL[(szIn[2] & 0x3F)] : '='; |
156 | // *pszB64Pt++ = (nIdxOfThree >= 2) ? B64CHARTBL[(szIn[2] & 0x3F)] : '='; | ||
157 | *pszB64Pt++ = (nIdxOfThree >= 2) ? B64CHARTBL[(szIn[2] & 0x3F)] : '-'; | ||
158 | 155 | ||
159 | memset((void *) szIn, 0, sizeof(szIn)); | 156 | memset((void *) szIn, 0, sizeof(szIn)); |
160 | } | 157 | } |
161 | *pszB64Pt = '\0'; | 158 | *pszB64Pt = '\0'; |
162 | 159 | ||
160 | pszB64 = qstrreplace("tr", pszB64, "+", "~"); | ||
161 | pszB64 = qstrreplace("tr", pszB64, "/", "_"); | ||
162 | pszB64 = qstrreplace("tr", pszB64, "=", "^"); | ||
163 | |||
163 | return pszB64; | 164 | return pszB64; |
164 | } | 165 | } |
165 | 166 | ||
@@ -180,11 +181,11 @@ size_t qB64_decode(char *str) { | |||
180 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 00-0F | 181 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 00-0F |
181 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 10-1F | 182 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 10-1F |
182 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, // 20-2F | 183 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 62, 64, 64, 64, 63, // 20-2F |
183 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 45, 64, 64, 64, 64, 64, 64, // 30-3F | 184 | 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 64, 64, 64, 64, 64, 64, // 30-3F |
184 | 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4F | 185 | 64, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4F |
185 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, // 50-5F | 186 | 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 64, 64, 64, 64, 64, // 50-5F |
186 | 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60-6F | 187 | 64, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60-6F |
187 | 41, 42, 43, 44, 45, 46, 95, 48, 49, 50, 51, 64, 64, 64, 64, 64, // 70-7F | 188 | 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 64, 64, 64, 64, 64, // 70-7F |
188 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 80-8F | 189 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 80-8F |
189 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 90-9F | 190 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // 90-9F |
190 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // A0-AF | 191 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, // A0-AF |
@@ -195,6 +196,10 @@ size_t qB64_decode(char *str) { | |||
195 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 // F0-FF | 196 | 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 // F0-FF |
196 | }; | 197 | }; |
197 | 198 | ||
199 | str = qstrreplace("tr", str, "~", "+"); | ||
200 | str = qstrreplace("tr", str, "_", "/"); | ||
201 | str = qstrreplace("tr", str, "^", "="); | ||
202 | |||
198 | char *pEncPt, *pBinPt = str; | 203 | char *pEncPt, *pBinPt = str; |
199 | int nIdxOfFour = 0; | 204 | int nIdxOfFour = 0; |
200 | char cLastByte = 0; | 205 | char cLastByte = 0; |