libpurple/util.c

branch
soc.2007.certmgr
changeset 17389
125a4df6d42c
parent 17287
72e491a54a63
child 18101
3ce21b5a182c
child 18105
bab0b0bcb664
equal deleted inserted replaced
17385:bf46968ab031 17389:125a4df6d42c
152 if (ret_len != NULL) 152 if (ret_len != NULL)
153 *ret_len = len / 2; 153 *ret_len = len / 2;
154 154
155 return data; 155 return data;
156 } 156 }
157
158 gchar *
159 purple_base16_encode_chunked(const guchar *data, gsize len)
160 {
161 int i;
162 gchar *ascii = NULL;
163
164 g_return_val_if_fail(data != NULL, NULL);
165 g_return_val_if_fail(len > 0, NULL);
166
167 /* For each byte of input, we need 2 bytes for the hex representation
168 * and 1 for the colon.
169 * The final colon will be replaced by a terminating NULL
170 */
171 ascii = g_malloc(len * 3 + 1);
172
173 for (i = 0; i < len; i++)
174 g_snprintf(&ascii[i * 3], 4, "%02hhx:", data[i]);
175
176 /* Replace the final colon with NULL */
177 ascii[len * 3 - 1] = 0;
178
179 return ascii;
180 }
181
157 182
158 /************************************************************************** 183 /**************************************************************************
159 * Base64 Functions 184 * Base64 Functions
160 **************************************************************************/ 185 **************************************************************************/
161 static const char alphabet[] = 186 static const char alphabet[] =

mercurial