MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / base64encode

Function base64encode

ut.c:298–324  ·  view source on GitHub ↗

function that encodes to base64 * output buffer is assumed to have the right length */

Source from the content-addressed store, hash-verified

296/* function that encodes to base64
297 * output buffer is assumed to have the right length */
298void base64encode(unsigned char *out, unsigned char *in, int inlen)
299{
300 for (; inlen >= 3; inlen -= 3)
301 {
302 *out++ = base64digits[in[0] >> 2];
303 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
304 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
305 *out++ = base64digits[in[2] & 0x3f];
306 in += 3;
307 }
308
309 if (inlen > 0)
310 {
311 unsigned char fragment;
312
313 *out++ = base64digits[in[0] >> 2];
314 fragment = (in[0] << 4) & 0x30;
315
316 if (inlen > 1)
317 fragment |= in[1] >> 4;
318
319 *out++ = base64digits[fragment];
320 *out++ = (inlen < 2) ? '=' : base64digits[(in[1] << 2) & 0x3c];
321 *out++ = '=';
322
323 }
324}
325
326/* function that encodes to base64URL
327 * output buffer is assumed to have the right length */

Callers 15

tr_eval_stringFunction · 0.85
serialize_he_rdataFunction · 0.85
serialize_dns_rdataFunction · 0.85
siprec_build_uuidFunction · 0.85
aka_av_newFunction · 0.85
fix_nated_contact_fFunction · 0.85
ws_compute_keyFunction · 0.85
build_contactFunction · 0.85
cdb_build_ucontact_keyFunction · 0.85
mc_compress_cbFunction · 0.85
insert_in_cachedbFunction · 0.85
generate_hep_guidFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected