MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / encode_base64

Function encode_base64

cmake/Windows/Contrib/Inetc/inetc.cpp:303–351  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303TCHAR *encode_base64(int size, TCHAR *src, TCHAR *dst) {
304
305 int i;
306 TCHAR *p;
307
308 if(!src)
309 return NULL;
310
311 if(!size)
312 size= lstrlen(src);
313
314 p = dst;
315
316 for(i=0; i<size; i+=3) {
317
318 unsigned char b1=0, b2=0, b3=0, b4=0, b5=0, b6=0, b7=0;
319
320 b1 = (unsigned char)src[i];
321
322 if(i+1<size)
323 b2 = (unsigned char)src[i+1];
324
325 if(i+2<size)
326 b3 = (unsigned char)src[i+2];
327
328 b4= b1>>2;
329 b5= ((b1&0x3)<<4)|(b2>>4);
330 b6= ((b2&0xf)<<2)|(b3>>6);
331 b7= b3&0x3f;
332
333 *p++= encode(b4);
334 *p++= encode(b5);
335
336 if(i+1<size) {
337 *p++= encode(b6);
338 } else {
339 *p++= TEXT('=');
340 }
341
342 if(i+2<size) {
343 *p++= encode(b7);
344 } else {
345 *p++= TEXT('=');
346 }
347
348 }
349
350 return dst;
351}
352
353/*****************************************************
354* FUNCTION NAME: fileTransfer()

Callers 2

inetTransferFunction · 0.85
getFunction · 0.85

Calls 1

encodeFunction · 0.85

Tested by

no test coverage detected