mirror of
https://tinyplantnews.com/git2/ldaphotos
synced 2025-01-10 10:25:15 +00:00
16 lines
377 B
C
16 lines
377 B
C
|
#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;
|
||
|
}
|