ldaphotos/sources/manipulations.c

16 lines
377 B
C
Raw Permalink Normal View History

#include <stdlib.h> // malloc
#include <stdio.h> // sprintf
char * atohex(unsigned char * a, size_t len, unsigned int * aalen){
char *aa;
//two bytes of output per byte of input, plus newline
(*aalen) = 2 * len * sizeof *aa + 1;
aa = (char*)malloc((*aalen));
for(int i = 0; i < len; i++){
sprintf(aa + (2 * i), "%02x", a[i]);
}
aa[(*aalen)-1] = '\n';
return aa;
}